// source --> https://manonc.fr/wp-content/plugins/woo-product-filter/js/core.js?ver=1.3.9
"use strict";
if(typeof(WPF_DATA) == 'undefined')
var WPF_DATA = {};
if(isNumber(WPF_DATA.animationSpeed))
WPF_DATA.animationSpeed = parseInt(WPF_DATA.animationSpeed);
else if(jQuery.inArray(WPF_DATA.animationSpeed, ['fast', 'slow']) == -1)
WPF_DATA.animationSpeed = 'fast';
WPF_DATA.showSubscreenOnCenter = parseInt(WPF_DATA.showSubscreenOnCenter);
var sdLoaderImgWpf = ' ';
var g_wpfAnimationSpeed = 300;
jQuery.fn.showLoaderWpf = function() {
return jQuery(this).html( sdLoaderImgWpf );
};
jQuery.fn.appendLoaderWpf = function() {
jQuery(this).append( sdLoaderImgWpf );
};
jQuery.sendFormWpf = function(params) {
// Any html element can be used here
return jQuery(' ').sendFormWpf(params);
};
/**
* Send form or just data to server by ajax and route response
* @param string params.fid form element ID, if empty - current element will be used
* @param string params.msgElID element ID to store result messages, if empty - element with ID "msg" will be used. Can be "noMessages" to not use this feature
* @param function params.onSuccess funstion to do after success receive response. Be advised - "success" means that ajax response will be success
* @param array params.data data to send if You don't want to send Your form data, will be set instead of all form data
* @param array params.appendData data to append to sending request. In contrast to params.data will not erase form data
* @param string params.inputsWraper element ID for inputs wraper, will be used if it is not a form
* @param string params.clearMsg clear msg element after receive data, if is number - will use it to set time for clearing, else - if true - will clear msg element after 5 seconds
*/
jQuery.fn.sendFormWpf = function(params) {
var form = null;
if(!params)
params = {fid: false, msgElID: false, onSuccess: false};
if(params.fid)
form = jQuery('#'+ fid);
else
form = jQuery(this);
/* This method can be used not only from form data sending, it can be used just to send some data and fill in response msg or errors*/
var sentFromForm = (jQuery(form).tagName() == 'FORM');
var data = new Array();
if(params.data)
data = params.data;
else if(sentFromForm)
data = jQuery(form).serialize();
if(params.appendData) {
var dataIsString = typeof(data) == 'string';
var addStrData = [];
for(var i in params.appendData) {
if(dataIsString) {
addStrData.push(i+ '='+ params.appendData[i]);
} else
data[i] = params.appendData[i];
}
if(dataIsString)
data += '&'+ addStrData.join('&');
}
var msgEl = null;
if(params.msgElID) {
if(params.msgElID == 'noMessages')
msgEl = false;
else if(typeof(params.msgElID) == 'object')
msgEl = params.msgElID;
else
msgEl = jQuery('#'+ params.msgElID);
}
if(typeof(params.inputsWraper) == 'string') {
form = jQuery('#'+ params.inputsWraper);
sentFromForm = true;
}
if(sentFromForm && form) {
jQuery(form).find('.wpfInputError').removeClass('wpfInputError');
}
if(msgEl && !params.btn) {
jQuery(msgEl)
.removeClass('wpfSuccessMsg')
.removeClass('wpfErrorMsg');
if(!params.btn) {
jQuery(msgEl).showLoaderWpf();
}
}
if(params.btn) {
jQuery(params.btn).attr('disabled', 'disabled');
// Font awesome usage
params.btnIconElement = jQuery(params.btn).find('.fa').length ? jQuery(params.btn).find('.fa') : jQuery(params.btn);
if(jQuery(params.btn).find('.fa').length) {
params.btnIconElement
.data('prev-class', params.btnIconElement.attr('class'))
.attr('class', 'fa fa-spinner fa-spin');
}
}
var url = '';
if(typeof(params.url) != 'undefined')
url = params.url;
else if(typeof(ajaxurl) == 'undefined' || typeof(ajaxurl) !== 'string')
url = WPF_DATA.ajaxurl;
else
url = ajaxurl;
jQuery('.wpfErrorForField').hide(WPF_DATA.animationSpeed);
var dataType = params.dataType ? params.dataType : 'json';
// Set plugin orientation
if(typeof(data) == 'string') {
data += '&pl='+ WPF_DATA.WPF_CODE;
data += '&reqType=ajax';
} else {
data['pl'] = WPF_DATA.WPF_CODE;
data['reqType'] = 'ajax';
}
jQuery.ajax({
url: url,
data: data,
type: 'POST',
dataType: dataType,
success: function(res) {
toeProcessAjaxResponseWpf(res, msgEl, form, sentFromForm, params);
if(params.clearMsg) {
setTimeout(function(){
if(msgEl)
jQuery(msgEl).animateClear();
}, typeof(params.clearMsg) == 'boolean' ? 5000 : params.clearMsg);
}
}
});
};
/**
* Hide content in element and then clear it
*/
jQuery.fn.animateClear = function() {
var newContent = jQuery(''+ jQuery(this).html()+ ' ');
jQuery(this).html( newContent );
jQuery(newContent).hide(WPF_DATA.animationSpeed, function(){
jQuery(newContent).remove();
});
};
/**
* Hide content in element and then remove it
*/
jQuery.fn.animateRemoveWpf = function(animationSpeed, onSuccess) {
animationSpeed = animationSpeed == undefined ? WPF_DATA.animationSpeed : animationSpeed;
jQuery(this).hide(animationSpeed, function(){
jQuery(this).remove();
if(typeof(onSuccess) === 'function')
onSuccess();
});
};
function toeProcessAjaxResponseWpf(res, msgEl, form, sentFromForm, params) {
if(typeof(params) == 'undefined')
params = {};
if(typeof(msgEl) == 'string')
msgEl = jQuery('#'+ msgEl);
if(msgEl)
jQuery(msgEl).html('');
if(params.btn) {
jQuery(params.btn).removeAttr('disabled');
if(params.btnIconElement) {
params.btnIconElement.attr('class', params.btnIconElement.data('prev-class'));
}
}
/*if(sentFromForm) {
jQuery(form).find('*').removeClass('wpfInputError');
}*/
if(typeof(res) == 'object') {
if(res.error) {
if(msgEl) {
jQuery(msgEl)
.removeClass('wpfSuccessMsg')
.addClass('wpfErrorMsg');
}
var errorsArr = [];
for(var name in res.errors) {
if(sentFromForm) {
var inputError = jQuery(form).find('[name*="'+ name+ '"]');
inputError.addClass('wpfInputError');
if(!inputError.data('keyup-error-remove-binded')) {
inputError.keydown(function(){
jQuery(this).removeClass('wpfInputError');
}).data('keyup-error-remove-binded', 1);
}
}
if(jQuery('.wpfErrorForField.toe_'+ nameToClassId(name)+ '').exists())
jQuery('.wpfErrorForField.toe_'+ nameToClassId(name)+ '').show().html(res.errors[name]);
else if(msgEl)
jQuery(msgEl).append(res.errors[name]).append(' ');
else
errorsArr.push( res.errors[name] );
}
if(errorsArr.length && params.btn && jQuery.fn.dialog && !msgEl) {
jQuery('
').html( errorsArr.join(' ') ).appendTo('body').dialog({
modal: true
, width: '500px'
});
}
} else if(res.messages.length) {
if(msgEl) {
jQuery(msgEl)
.removeClass('wpfErrorMsg')
.addClass('wpfSuccessMsg');
for(var i = 0; i < res.messages.length; i++) {
jQuery(msgEl).append(res.messages[i]).append(' ');
}
}
}
}
if(params.onSuccess && typeof(params.onSuccess) == 'function') {
params.onSuccess(res);
}
}
function getDialogElementWpf() {
return jQuery('
').appendTo(jQuery('body'));
}
function toeOptionWpf(key) {
if(WPF_DATA.options && WPF_DATA.options[ key ])
return WPF_DATA.options[ key ];
return false;
}
function toeLangWpf(key) {
if(WPF_DATA.siteLang && WPF_DATA.siteLang[key])
return WPF_DATA.siteLang[key];
return key;
}
function toePagesWpf(key) {
if(typeof(WPF_DATA) != 'undefined' && WPF_DATA[key])
return WPF_DATA[key];
return false;;
}
/**
* This function will help us not to hide desc right now, but wait - maybe user will want to select some text or click on some link in it.
*/
function toeOptTimeoutHideDescriptionWpf() {
jQuery('#wpfOptDescription').removeAttr('toeFixTip');
setTimeout(function(){
if(!jQuery('#wpfOptDescription').attr('toeFixTip'))
toeOptHideDescriptionWpf();
}, 500);
}
/**
* Show description for options
*/
function toeOptShowDescriptionWpf(description, x, y, moveToLeft) {
if(typeof(description) != 'undefined' && description != '') {
if(!jQuery('#wpfOptDescription').length) {
jQuery('body').append('
');
}
if(moveToLeft)
jQuery('#wpfOptDescription').css('right', jQuery(window).width() - (x - 10)); // Show it on left side of target
else
jQuery('#wpfOptDescription').css('left', x + 10);
jQuery('#wpfOptDescription').css('top', y);
jQuery('#wpfOptDescription').show(200);
jQuery('#wpfOptDescription').html(description);
}
}
/**
* Hide description for options
*/
function toeOptHideDescriptionWpf() {
jQuery('#wpfOptDescription').removeAttr('toeFixTip');
jQuery('#wpfOptDescription').hide(200);
}
function toeInArrayWpf(needle, haystack) {
if(haystack) {
for(var i in haystack) {
if(haystack[i] == needle)
return true;
}
}
return false;
}
function toeShowDialogCustomized(element, options) {
options = jQuery.extend({
resizable: false
, width: 500
, height: 300
, closeOnEscape: true
, open: function(event, ui) {
jQuery('.ui-dialog-titlebar').css({
'background-color': '#222222'
, 'background-image': 'none'
, 'border': 'none'
, 'margin': '0'
, 'padding': '0'
, 'border-radius': '0'
, 'color': '#CFCFCF'
, 'height': '27px'
});
jQuery('.ui-dialog-titlebar-close').css({
'background': 'url("'+ WPF_DATA.cssPath+ 'img/tb-close.png") no-repeat scroll 0 0 transparent'
, 'border': '0'
, 'width': '15px'
, 'height': '15px'
, 'padding': '0'
, 'border-radius': '0'
, 'margin': '7px 7px 0'
}).html('');
jQuery('.ui-dialog').css({
'border-radius': '3px'
, 'background-color': '#FFFFFF'
, 'background-image': 'none'
, 'padding': '1px'
, 'z-index': '300000'
, 'position': 'fixed'
, 'top': '60px'
});
jQuery('.ui-dialog-buttonpane').css({
'background-color': '#FFFFFF'
});
jQuery('.ui-dialog-title').css({
'color': '#CFCFCF'
, 'font': '12px sans-serif'
, 'padding': '6px 10px 0'
});
if(options.openCallback && typeof(options.openCallback) == 'function') {
options.openCallback(event, ui);
}
jQuery('.ui-widget-overlay').css({
'z-index': jQuery( event.target ).parents('.ui-dialog:first').css('z-index') - 1
, 'background-image': 'none'
});
if(options.modal && options.closeOnBg) {
jQuery('.ui-widget-overlay').unbind('click').bind('click', function() {
jQuery( element ).dialog('close');
});
}
}
}, options);
return jQuery(element).dialog(options);
}
/**
* @see html::slider();
**/
function toeSliderMove(event, ui) {
var id = jQuery(event.target).attr('id');
jQuery('#toeSliderDisplay_'+ id).html( ui.value );
jQuery('#toeSliderInput_'+ id).val( ui.value ).change();
}
function wpfCorrectJqueryUsed() {
return (typeof(jQuery.fn.sendFormWpf) === 'function');
}
function wpfReloadCoreJs(clb, params) {
var scriptsHtml = ''
, coreScripts = ['common.js', 'core.js'];
for(var i = 0; i < coreScripts.length; i++) {
scriptsHtml += '';
}
jQuery('head').append( scriptsHtml );
if(clb) {
_wpfRunClbAfterCoreReload( clb, params );
}
}
function _wpfRunClbAfterCoreReload(clb, params) {
if(wpfCorrectJqueryUsed()) {
callUserFuncArray(clb, params);
return;
}
setTimeout(function(){
wpfCorrectJqueryUsed(clb, params);
}, 500);
}
function wpfGetStyleSheetRule(sheetId, rule, isLike) {
var obj = document.getElementById(sheetId),
sheet = obj.sheet || obj.styleSheet,
rules = sheet.cssRules || sheet.rules,
isLike = typeof isLike == 'undefined' ? false : isLike;
for (var r = 0; r < rules.length; r++) {
if(isLike) {
if(rules[r].selectorText.indexOf(rule) === 0) return rules[r];
} else if(rules[r].selectorText == rule) return rules[r];
}
return false;
}
function wpfGetColorText(bg) {
if(typeof bg !== 'undefined' && bg.length >= 7) {
var rgb = (/^#[0-9A-F]{6}$/i.test(bg))
? [0, parseInt(bg.substring(1,3),16), parseInt(bg.substring(3,5),16), parseInt(bg.substring(5,7),16)]
: bg.replace(/\s/g,'').match(/^rgba?\((\d+),(\d+),(\d+)/i);
if(rgb.length >= 4 && (1 - (0.299 * rgb[1] + 0.587 * rgb[2] + 0.114 * rgb[3]) / 255) > 0.5) return '#dddddd';
}
return '#444444';
}
function wpfLightenDarkenColor(col, amt) {
var usePound = false,
r = 255,
g = 255,
b = 255;
if(typeof col !== 'undefined' && col.length >= 7) {
if(col.indexOf('rgb') == -1) {
if(col[0] == "#") {
col = col.slice(1);
usePound = true;
}
var num = parseInt(col, 16);
r = (num >> 16);
b = ((num >> 8) & 0x00FF);
g = (num & 0x0000FF);
} else {
var withA = col.indexOf('rgba') != -1,
rgb = withA ? col.replace(/\s/g,'').match(/^rgba?\((\d+),(\d+),(\d+),(\d+)/i) : col.replace(/\s/g,'').match(/^rgba?\((\d+),(\d+),(\d+)/i);
if(rgb.length >= 4) {
var a = withA ? rgb[3] : 1,
bg = (1 - a) * 255;
r = rgb[1] * a + bg;
g = rgb[2] * a + bg;
b = rgb[3] * a + bg;
}
usePound = true;
}
}
r = r + amt;
b = b + amt;
g = g + amt;
if(r > 255) r = 255;
else if(r < 0) r = 0;
if(b > 255) b = 255;
else if(b < 0) b = 0;
if(g > 255) g = 255;
else if(g < 0) g = 0;
var res = (g | (b << 8) | (r << 16)).toString(16);
return (usePound?"#":"") + '0'.repeat(6 - res.length) + res;
};
// source --> https://manonc.fr/wp-content/plugins/woo-product-filter/modules/templates/lib/tooltipster/jquery.tooltipster.min.js?ver=1.3.9
/* Tooltipster v3.3.0 */;(function(e,t,n){function s(t,n){this.bodyOverflowX;this.callbacks={hide:[],show:[]};this.checkInterval=null;this.Content;this.$el=e(t);this.$elProxy;this.elProxyPosition;this.enabled=true;this.options=e.extend({},i,n);this.mouseIsOverProxy=false;this.namespace="tooltipster-"+Math.round(Math.random()*1e5);this.Status="hidden";this.timerHide=null;this.timerShow=null;this.$tooltip;this.options.iconTheme=this.options.iconTheme.replace(".","");this.options.theme=this.options.theme.replace(".","");this._init()}function o(t,n){var r=true;e.each(t,function(e,i){if(typeof n[e]==="undefined"||t[e]!==n[e]){r=false;return false}});return r}function f(){return!a&&u}function l(){var e=n.body||n.documentElement,t=e.style,r="transition";if(typeof t[r]=="string"){return true}v=["Moz","Webkit","Khtml","O","ms"],r=r.charAt(0).toUpperCase()+r.substr(1);for(var i=0;i');t.$elProxy.text(t.options.icon)}else{if(t.options.iconCloning)t.$elProxy=t.options.icon.clone(true);else t.$elProxy=t.options.icon}t.$elProxy.insertAfter(t.$el)}else{t.$elProxy=t.$el}if(t.options.trigger=="hover"){t.$elProxy.on("mouseenter."+t.namespace,function(){if(!f()||t.options.touchDevices){t.mouseIsOverProxy=true;t._show()}}).on("mouseleave."+t.namespace,function(){if(!f()||t.options.touchDevices){t.mouseIsOverProxy=false}});if(u&&t.options.touchDevices){t.$elProxy.on("touchstart."+t.namespace,function(){t._showNow()})}}else if(t.options.trigger=="click"){t.$elProxy.on("click."+t.namespace,function(){if(!f()||t.options.touchDevices){t._show()}})}}},_show:function(){var e=this;if(e.Status!="shown"&&e.Status!="appearing"){if(e.options.delay){e.timerShow=setTimeout(function(){if(e.options.trigger=="click"||e.options.trigger=="hover"&&e.mouseIsOverProxy){e._showNow()}},e.options.delay)}else e._showNow()}},_showNow:function(n){var r=this;r.options.functionBefore.call(r.$el,r.$el,function(){if(r.enabled&&r.Content!==null){if(n)r.callbacks.show.push(n);r.callbacks.hide=[];clearTimeout(r.timerShow);r.timerShow=null;clearTimeout(r.timerHide);r.timerHide=null;if(r.options.onlyOne){e(".tooltipstered").not(r.$el).each(function(t,n){var r=e(n),i=r.data("tooltipster-ns");e.each(i,function(e,t){var n=r.data(t),i=n.status(),s=n.option("autoClose");if(i!=="hidden"&&i!=="disappearing"&&s){n.hide()}})})}var i=function(){r.Status="shown";e.each(r.callbacks.show,function(e,t){t.call(r.$el)});r.callbacks.show=[]};if(r.Status!=="hidden"){var s=0;if(r.Status==="disappearing"){r.Status="appearing";if(l()){r.$tooltip.clearQueue().removeClass("tooltipster-dying").addClass("tooltipster-"+r.options.animation+"-show");if(r.options.speed>0)r.$tooltip.delay(r.options.speed);r.$tooltip.queue(i)}else{r.$tooltip.stop().fadeIn(i)}}else if(r.Status==="shown"){i()}}else{r.Status="appearing";var s=r.options.speed;r.bodyOverflowX=e("body").css("overflow-x");e("body").css("overflow-x","hidden");var o="tooltipster-"+r.options.animation,a="-webkit-transition-duration: "+r.options.speed+"ms; -webkit-animation-duration: "+r.options.speed+"ms; -moz-transition-duration: "+r.options.speed+"ms; -moz-animation-duration: "+r.options.speed+"ms; -o-transition-duration: "+r.options.speed+"ms; -o-animation-duration: "+r.options.speed+"ms; -ms-transition-duration: "+r.options.speed+"ms; -ms-animation-duration: "+r.options.speed+"ms; transition-duration: "+r.options.speed+"ms; animation-duration: "+r.options.speed+"ms;",f=r.options.minWidth?"min-width:"+Math.round(r.options.minWidth)+"px;":"",c=r.options.maxWidth?"max-width:"+Math.round(r.options.maxWidth)+"px;":"",h=r.options.interactive?"pointer-events: auto;":"";r.$tooltip=e('');if(l())r.$tooltip.addClass(o);r._content_insert();r.$tooltip.appendTo("body");r.reposition();r.options.functionReady.call(r.$el,r.$el,r.$tooltip);if(l()){r.$tooltip.addClass(o+"-show");if(r.options.speed>0)r.$tooltip.delay(r.options.speed);r.$tooltip.queue(i)}else{r.$tooltip.css("display","none").fadeIn(r.options.speed,i)}r._interval_set();e(t).on("scroll."+r.namespace+" resize."+r.namespace,function(){r.reposition()});if(r.options.autoClose){e("body").off("."+r.namespace);if(r.options.trigger=="hover"){if(u){setTimeout(function(){e("body").on("touchstart."+r.namespace,function(){r.hide()})},0)}if(r.options.interactive){if(u){r.$tooltip.on("touchstart."+r.namespace,function(e){e.stopPropagation()})}var p=null;r.$elProxy.add(r.$tooltip).on("mouseleave."+r.namespace+"-autoClose",function(){clearTimeout(p);p=setTimeout(function(){r.hide()},r.options.interactiveTolerance)}).on("mouseenter."+r.namespace+"-autoClose",function(){clearTimeout(p)})}else{r.$elProxy.on("mouseleave."+r.namespace+"-autoClose",function(){r.hide()})}if(r.options.hideOnClick){r.$elProxy.on("click."+r.namespace+"-autoClose",function(){r.hide()})}}else if(r.options.trigger=="click"){setTimeout(function(){e("body").on("click."+r.namespace+" touchstart."+r.namespace,function(){r.hide()})},0);if(r.options.interactive){r.$tooltip.on("click."+r.namespace+" touchstart."+r.namespace,function(e){e.stopPropagation()})}}}}if(r.options.timer>0){r.timerHide=setTimeout(function(){r.timerHide=null;r.hide()},r.options.timer+s)}}})},_interval_set:function(){var t=this;t.checkInterval=setInterval(function(){if(e("body").find(t.$el).length===0||e("body").find(t.$elProxy).length===0||t.Status=="hidden"||e("body").find(t.$tooltip).length===0){if(t.Status=="shown"||t.Status=="appearing")t.hide();t._interval_cancel()}else{if(t.options.positionTracker){var n=t._repositionInfo(t.$elProxy),r=false;if(o(n.dimension,t.elProxyPosition.dimension)){if(t.$elProxy.css("position")==="fixed"){if(o(n.position,t.elProxyPosition.position))r=true}else{if(o(n.offset,t.elProxyPosition.offset))r=true}}if(!r){t.reposition();t.options.positionTrackerCallback.call(t,t.$el)}}}},200)},_interval_cancel:function(){clearInterval(this.checkInterval);this.checkInterval=null},_content_set:function(e){if(typeof e==="object"&&e!==null&&this.options.contentCloning){e=e.clone(true)}this.Content=e},_content_insert:function(){var e=this,t=this.$tooltip.find(".tooltipster-content");if(typeof e.Content==="string"&&!e.options.contentAsHTML){t.text(e.Content)}else{t.empty().append(e.Content)}},_update:function(e){var t=this;t._content_set(e);if(t.Content!==null){if(t.Status!=="hidden"){t._content_insert();t.reposition();if(t.options.updateAnimation){if(l()){t.$tooltip.css({width:"","-webkit-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms","-moz-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms","-o-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms","-ms-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms",transition:"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms"}).addClass("tooltipster-content-changing");setTimeout(function(){if(t.Status!="hidden"){t.$tooltip.removeClass("tooltipster-content-changing");setTimeout(function(){if(t.Status!=="hidden"){t.$tooltip.css({"-webkit-transition":t.options.speed+"ms","-moz-transition":t.options.speed+"ms","-o-transition":t.options.speed+"ms","-ms-transition":t.options.speed+"ms",transition:t.options.speed+"ms"})}},t.options.speed)}},t.options.speed)}else{t.$tooltip.fadeTo(t.options.speed,.5,function(){if(t.Status!="hidden"){t.$tooltip.fadeTo(t.options.speed,1)}})}}}}else{t.hide()}},_repositionInfo:function(e){return{dimension:{height:e.outerHeight(false),width:e.outerWidth(false)},offset:e.offset(),position:{left:parseInt(e.css("left")),top:parseInt(e.css("top"))}}},hide:function(n){var r=this;if(n)r.callbacks.hide.push(n);r.callbacks.show=[];clearTimeout(r.timerShow);r.timerShow=null;clearTimeout(r.timerHide);r.timerHide=null;var i=function(){e.each(r.callbacks.hide,function(e,t){t.call(r.$el)});r.callbacks.hide=[]};if(r.Status=="shown"||r.Status=="appearing"){r.Status="disappearing";var s=function(){r.Status="hidden";if(typeof r.Content=="object"&&r.Content!==null){r.Content.detach()}r.$tooltip.remove();r.$tooltip=null;e(t).off("."+r.namespace);e("body").off("."+r.namespace).css("overflow-x",r.bodyOverflowX);e("body").off("."+r.namespace);r.$elProxy.off("."+r.namespace+"-autoClose");r.options.functionAfter.call(r.$el,r.$el);i()};if(l()){r.$tooltip.clearQueue().removeClass("tooltipster-"+r.options.animation+"-show").addClass("tooltipster-dying");if(r.options.speed>0)r.$tooltip.delay(r.options.speed);r.$tooltip.queue(s)}else{r.$tooltip.stop().fadeOut(r.options.speed,s)}}else if(r.Status=="hidden"){i()}return r},show:function(e){this._showNow(e);return this},update:function(e){return this.content(e)},content:function(e){if(typeof e==="undefined"){return this.Content}else{this._update(e);return this}},reposition:function(){var n=this;if(e("body").find(n.$tooltip).length!==0){n.$tooltip.css("width","");n.elProxyPosition=n._repositionInfo(n.$elProxy);var r=null,i=e(t).width(),s=n.elProxyPosition,o=n.$tooltip.outerWidth(false),u=n.$tooltip.innerWidth()+1,a=n.$tooltip.outerHeight(false);if(n.$elProxy.is("area")){var f=n.$elProxy.attr("shape"),l=n.$elProxy.parent().attr("name"),c=e('img[usemap="#'+l+'"]'),h=c.offset().left,p=c.offset().top,d=n.$elProxy.attr("coords")!==undefined?n.$elProxy.attr("coords").split(","):undefined;if(f=="circle"){var v=parseInt(d[0]),m=parseInt(d[1]),g=parseInt(d[2]);s.dimension.height=g*2;s.dimension.width=g*2;s.offset.top=p+m-g;s.offset.left=h+v-g}else if(f=="rect"){var v=parseInt(d[0]),m=parseInt(d[1]),y=parseInt(d[2]),b=parseInt(d[3]);s.dimension.height=b-m;s.dimension.width=y-v;s.offset.top=p+m;s.offset.left=h+v}else if(f=="poly"){var w=[],E=[],S=0,x=0,T=0,N=0,C="even";for(var k=0;kT){T=L;if(k===0){S=T}}if(LN){N=L;if(k==1){x=N}}if(Li){r=A-(i+n-o);A=i+n-o}}function B(n,r){if(s.offset.top-e(t).scrollTop()-a-_-12<0&&r.indexOf("top")>-1){P=n}if(s.offset.top+s.dimension.height+a+12+_>e(t).scrollTop()+e(t).height()&&r.indexOf("bottom")>-1){P=n;M=s.offset.top-a-_-12}}if(P=="top"){var j=s.offset.left+o-(s.offset.left+s.dimension.width);A=s.offset.left+D-j/2;M=s.offset.top-a-_-12;H();B("bottom","top")}if(P=="top-left"){A=s.offset.left+D;M=s.offset.top-a-_-12;H();B("bottom-left","top-left")}if(P=="top-right"){A=s.offset.left+s.dimension.width+D-o;M=s.offset.top-a-_-12;H();B("bottom-right","top-right")}if(P=="bottom"){var j=s.offset.left+o-(s.offset.left+s.dimension.width);A=s.offset.left-j/2+D;M=s.offset.top+s.dimension.height+_+12;H();B("top","bottom")}if(P=="bottom-left"){A=s.offset.left+D;M=s.offset.top+s.dimension.height+_+12;H();B("top-left","bottom-left")}if(P=="bottom-right"){A=s.offset.left+s.dimension.width+D-o;M=s.offset.top+s.dimension.height+_+12;H();B("top-right","bottom-right")}if(P=="left"){A=s.offset.left-D-o-12;O=s.offset.left+D+s.dimension.width+12;var F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_;if(A<0&&O+o>i){var I=parseFloat(n.$tooltip.css("border-width"))*2,q=o+A-I;n.$tooltip.css("width",q+"px");a=n.$tooltip.outerHeight(false);A=s.offset.left-D-q-12-I;F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_}else if(A<0){A=s.offset.left+D+s.dimension.width+12;r="left"}}if(P=="right"){A=s.offset.left+D+s.dimension.width+12;O=s.offset.left-D-o-12;var F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_;if(A+o>i&&O<0){var I=parseFloat(n.$tooltip.css("border-width"))*2,q=i-A-I;n.$tooltip.css("width",q+"px");a=n.$tooltip.outerHeight(false);F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_}else if(A+o>i){A=s.offset.left-D-o-12;r="right"}}if(n.options.arrow){var R="tooltipster-arrow-"+P;if(n.options.arrowColor.length<1){var U=n.$tooltip.css("background-color")}else{var U=n.options.arrowColor}if(!r){r=""}else if(r=="left"){R="tooltipster-arrow-right";r=""}else if(r=="right"){R="tooltipster-arrow-left";r=""}else{r="left:"+Math.round(r)+"px;"}if(P=="top"||P=="top-left"||P=="top-right"){var z=parseFloat(n.$tooltip.css("border-bottom-width")),W=n.$tooltip.css("border-bottom-color")}else if(P=="bottom"||P=="bottom-left"||P=="bottom-right"){var z=parseFloat(n.$tooltip.css("border-top-width")),W=n.$tooltip.css("border-top-color")}else if(P=="left"){var z=parseFloat(n.$tooltip.css("border-right-width")),W=n.$tooltip.css("border-right-color")}else if(P=="right"){var z=parseFloat(n.$tooltip.css("border-left-width")),W=n.$tooltip.css("border-left-color")}else{var z=parseFloat(n.$tooltip.css("border-bottom-width")),W=n.$tooltip.css("border-bottom-color")}if(z>1){z++}var X="";if(z!==0){var V="",J="border-color: "+W+";";if(R.indexOf("bottom")!==-1){V="margin-top: -"+Math.round(z)+"px;"}else if(R.indexOf("top")!==-1){V="margin-bottom: -"+Math.round(z)+"px;"}else if(R.indexOf("left")!==-1){V="margin-right: -"+Math.round(z)+"px;"}else if(R.indexOf("right")!==-1){V="margin-left: -"+Math.round(z)+"px;"}X=' '}n.$tooltip.find(".tooltipster-arrow").remove();var K=''+X+'
';n.$tooltip.append(K)}n.$tooltip.css({top:Math.round(M)+"px",left:Math.round(A)+"px"})}return n},enable:function(){this.enabled=true;return this},disable:function(){this.hide();this.enabled=false;return this},destroy:function(){var t=this;t.hide();if(t.$el[0]!==t.$elProxy[0]){t.$elProxy.remove()}t.$el.removeData(t.namespace).off("."+t.namespace);var n=t.$el.data("tooltipster-ns");if(n.length===1){var r=null;if(t.options.restoration==="previous"){r=t.$el.data("tooltipster-initialTitle")}else if(t.options.restoration==="current"){r=typeof t.Content==="string"?t.Content:e("
").append(t.Content).html()}if(r){t.$el.attr("title",r)}t.$el.removeClass("tooltipstered").removeData("tooltipster-ns").removeData("tooltipster-initialTitle")}else{n=e.grep(n,function(e,n){return e!==t.namespace});t.$el.data("tooltipster-ns",n)}return t},elementIcon:function(){return this.$el[0]!==this.$elProxy[0]?this.$elProxy[0]:undefined},elementTooltip:function(){return this.$tooltip?this.$tooltip[0]:undefined},option:function(e,t){if(typeof t=="undefined")return this.options[e];else{this.options[e]=t;return this}},status:function(){return this.Status}};e.fn[r]=function(){var t=arguments;if(this.length===0){if(typeof t[0]==="string"){var n=true;switch(t[0]){case"setDefaults":e.extend(i,t[1]);break;default:n=false;break}if(n)return true;else return this}else{return this}}else{if(typeof t[0]==="string"){var r="#*$~&";this.each(function(){var n=e(this).data("tooltipster-ns"),i=n?e(this).data(n[0]):null;if(i){if(typeof i[t[0]]==="function"){var s=i[t[0]](t[1],t[2])}else{throw new Error('Unknown method .tooltipster("'+t[0]+'")')}if(s!==i){r=s;return false}}else{throw new Error("You called Tooltipster's \""+t[0]+'" method on an uninitialized element')}});return r!=="#*$~&"?r:this}else{var o=[],u=t[0]&&typeof t[0].multiple!=="undefined",a=u&&t[0].multiple||!u&&i.multiple,f=t[0]&&typeof t[0].debug!=="undefined",l=f&&t[0].debug||!f&&i.debug;this.each(function(){var n=false,r=e(this).data("tooltipster-ns"),i=null;if(!r){n=true}else if(a){n=true}else if(l){console.log('Tooltipster: one or more tooltips are already attached to this element: ignoring. Use the "multiple" option to attach more tooltips.')}if(n){i=new s(this,t[0]);if(!r)r=[];r.push(i.namespace);e(this).data("tooltipster-ns",r);e(this).data(i.namespace,i)}o.push(i)});if(a)return o;else return this}}};var u=!!("ontouchstart"in t);var a=false;e("body").one("mousemove",function(){a=true})})(jQuery,window,document);
// source --> https://manonc.fr/wp-content/plugins/woo-product-filter/modules/templates/lib/chosen/chosen.jquery.min.js?ver=1.3.9
/* Chosen v1.1.0 | (c) 2011-2013 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
!function(){var a,AbstractChosen,Chosen,SelectParser,b,c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};SelectParser=function(){function SelectParser(){this.options_index=0,this.parsed=[]}return SelectParser.prototype.add_node=function(a){return"OPTGROUP"===a.nodeName.toUpperCase()?this.add_group(a):this.add_option(a)},SelectParser.prototype.add_group=function(a){var b,c,d,e,f,g;for(b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:this.escapeExpression(a.label),children:0,disabled:a.disabled}),f=a.childNodes,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(this.add_option(c,b,a.disabled));return g},SelectParser.prototype.add_option=function(a,b,c){return"OPTION"===a.nodeName.toUpperCase()?(""!==a.text?(null!=b&&(this.parsed[b].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:a.value,text:a.text,html:a.innerHTML,selected:a.selected,disabled:c===!0?c:a.disabled,group_array_index:b,classes:a.className,style:a.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1):void 0},SelectParser.prototype.escapeExpression=function(a){var b,c;return null==a||a===!1?"":/[\&\<\>\"\'\`]/.test(a)?(b={"<":"<",">":">",'"':""","'":"'","`":"`"},c=/&(?!\w+;)|[\<\>\"\'\`]/g,a.replace(c,function(a){return b[a]||"&"})):a},SelectParser}(),SelectParser.select_to_array=function(a){var b,c,d,e,f;for(c=new SelectParser,f=a.childNodes,d=0,e=f.length;e>d;d++)b=f[d],c.add_node(b);return c.parsed},AbstractChosen=function(){function AbstractChosen(a,b){this.form_field=a,this.options=null!=b?b:{},AbstractChosen.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers())}return AbstractChosen.prototype.set_default_values=function(){var a=this;return this.click_test_action=function(b){return a.test_active_click(b)},this.activate_action=function(b){return a.activate_field(b)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null!=this.options.enable_split_word_search?this.options.enable_split_word_search:!0,this.group_search=null!=this.options.group_search?this.options.group_search:!0,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null!=this.options.single_backstroke_delete?this.options.single_backstroke_delete:!0,this.max_selected_options=this.options.max_selected_options||1/0,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null!=this.options.display_selected_options?this.options.display_selected_options:!0,this.display_disabled_options=null!=this.options.display_disabled_options?this.options.display_disabled_options:!0},AbstractChosen.prototype.set_default_text=function(){return this.default_text=this.form_field.getAttribute("data-placeholder")?this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.options.placeholder_text_multiple||this.options.placeholder_text||AbstractChosen.default_multiple_text:this.options.placeholder_text_single||this.options.placeholder_text||AbstractChosen.default_single_text,this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||AbstractChosen.default_no_result_text},AbstractChosen.prototype.mouse_enter=function(){return this.mouse_on_container=!0},AbstractChosen.prototype.mouse_leave=function(){return this.mouse_on_container=!1},AbstractChosen.prototype.input_focus=function(){var a=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return a.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},AbstractChosen.prototype.input_blur=function(){var a=this;return this.mouse_on_container?void 0:(this.active_field=!1,setTimeout(function(){return a.blur_test()},100))},AbstractChosen.prototype.results_option_build=function(a){var b,c,d,e,f;for(b="",f=this.results_data,d=0,e=f.length;e>d;d++)c=f[d],b+=c.group?this.result_add_group(c):this.result_add_option(c),(null!=a?a.first:void 0)&&(c.selected&&this.is_multiple?this.choice_build(c):c.selected&&!this.is_multiple&&this.single_set_selected_text(c.text));return b},AbstractChosen.prototype.result_add_option=function(a){var b,c;return a.search_match?this.include_option_in_results(a)?(b=[],a.disabled||a.selected&&this.is_multiple||b.push("active-result"),!a.disabled||a.selected&&this.is_multiple||b.push("disabled-result"),a.selected&&b.push("result-selected"),null!=a.group_array_index&&b.push("group-option"),""!==a.classes&&b.push(a.classes),c=document.createElement("li"),c.className=b.join(" "),c.style.cssText=a.style,c.setAttribute("data-option-array-index",a.array_index),c.innerHTML=a.search_text,this.outerHTML(c)):"":""},AbstractChosen.prototype.result_add_group=function(a){var b;return a.search_match||a.group_match?a.active_options>0?(b=document.createElement("li"),b.className="group-result",b.innerHTML=a.search_text,this.outerHTML(b)):"":""},AbstractChosen.prototype.results_update_field=function(){return this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.results_build(),this.results_showing?this.winnow_results():void 0},AbstractChosen.prototype.reset_single_select_options=function(){var a,b,c,d,e;for(d=this.results_data,e=[],b=0,c=d.length;c>b;b++)a=d[b],a.selected?e.push(a.selected=!1):e.push(void 0);return e},AbstractChosen.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},AbstractChosen.prototype.results_search=function(){return this.results_showing?this.winnow_results():this.results_show()},AbstractChosen.prototype.winnow_results=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m;for(this.no_results_clear(),e=0,g=this.get_search_text(),a=g.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),d=this.search_contains?"":"^",c=new RegExp(d+a,"i"),j=new RegExp(a,"i"),m=this.results_data,k=0,l=m.length;l>k;k++)b=m[k],b.search_match=!1,f=null,this.include_option_in_results(b)&&(b.group&&(b.group_match=!1,b.active_options=0),null!=b.group_array_index&&this.results_data[b.group_array_index]&&(f=this.results_data[b.group_array_index],0===f.active_options&&f.search_match&&(e+=1),f.active_options+=1),(!b.group||this.group_search)&&(b.search_text=b.group?b.label:b.html,b.search_match=this.search_string_match(b.search_text,c),b.search_match&&!b.group&&(e+=1),b.search_match?(g.length&&(h=b.search_text.search(j),i=b.search_text.substr(0,h+g.length)+""+b.search_text.substr(h+g.length),b.search_text=i.substr(0,h)+""+i.substr(h)),null!=f&&(f.group_match=!0)):null!=b.group_array_index&&this.results_data[b.group_array_index].search_match&&(b.search_match=!0)));return this.result_clear_highlight(),1>e&&g.length?(this.update_results_content(""),this.no_results(g)):(this.update_results_content(this.results_option_build()),this.winnow_results_set_highlight())},AbstractChosen.prototype.search_string_match=function(a,b){var c,d,e,f;if(b.test(a))return!0;if(this.enable_split_word_search&&(a.indexOf(" ")>=0||0===a.indexOf("["))&&(d=a.replace(/\[|\]/g,"").split(" "),d.length))for(e=0,f=d.length;f>e;e++)if(c=d[e],b.test(c))return!0},AbstractChosen.prototype.choices_count=function(){var a,b,c,d;if(null!=this.selected_option_count)return this.selected_option_count;for(this.selected_option_count=0,d=this.form_field.options,b=0,c=d.length;c>b;b++)a=d[b],a.selected&&(this.selected_option_count+=1);return this.selected_option_count},AbstractChosen.prototype.choices_click=function(a){return a.preventDefault(),this.results_showing||this.is_disabled?void 0:this.results_show()},AbstractChosen.prototype.keyup_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:if(a.preventDefault(),this.results_showing)return this.result_select(a);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},AbstractChosen.prototype.clipboard_event_checker=function(){var a=this;return setTimeout(function(){return a.results_search()},50)},AbstractChosen.prototype.container_width=function(){return null!=this.options.width?this.options.width:""+this.form_field.offsetWidth+"px"},AbstractChosen.prototype.include_option_in_results=function(a){return this.is_multiple&&!this.display_selected_options&&a.selected?!1:!this.display_disabled_options&&a.disabled?!1:a.empty?!1:!0},AbstractChosen.prototype.search_results_touchstart=function(a){return this.touch_started=!0,this.search_results_mouseover(a)},AbstractChosen.prototype.search_results_touchmove=function(a){return this.touch_started=!1,this.search_results_mouseout(a)},AbstractChosen.prototype.search_results_touchend=function(a){return this.touch_started?this.search_results_mouseup(a):void 0},AbstractChosen.prototype.outerHTML=function(a){var b;return a.outerHTML?a.outerHTML:(b=document.createElement("div"),b.appendChild(a),b.innerHTML)},AbstractChosen.browser_is_supported=function(){return"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:/iP(od|hone)/i.test(window.navigator.userAgent)?!1:/Android/i.test(window.navigator.userAgent)&&/Mobile/i.test(window.navigator.userAgent)?!1:!0},AbstractChosen.default_multiple_text="Select Some Options",AbstractChosen.default_single_text="Select an Option",AbstractChosen.default_no_result_text="No results match",AbstractChosen}(),a=jQuery,a.fn.extend({chosen:function(b){return AbstractChosen.browser_is_supported()?this.each(function(){var c,d;c=a(this),d=c.data("chosen"),"destroy"===b&&d?d.destroy():d||c.data("chosen",new Chosen(this,b))}):this}}),Chosen=function(c){function Chosen(){return b=Chosen.__super__.constructor.apply(this,arguments)}return d(Chosen,c),Chosen.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.current_selectedIndex=this.form_field.selectedIndex,this.is_rtl=this.form_field_jq.hasClass("chosen-rtl")},Chosen.prototype.set_up_html=function(){var b,c;return b=["chosen-container"],b.push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&b.push(this.form_field.className),this.is_rtl&&b.push("chosen-rtl"),c={"class":b.join(" "),style:"width: "+this.container_width()+";",title:this.form_field.title},this.form_field.id.length&&(c.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=a("
",c),this.is_multiple?this.container.html(''):this.container.html(''+this.default_text+'
'),this.form_field_jq.hide().after(this.container),this.dropdown=this.container.find("div.chosen-drop").first(),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chosen-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chosen-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chosen-search").first(),this.selected_item=this.container.find(".chosen-single").first()),this.results_build(),this.set_tab_index(),this.set_label_behavior(),this.form_field_jq.trigger("chosen:ready",{chosen:this})},Chosen.prototype.register_observers=function(){var a=this;return this.container.bind("mousedown.chosen",function(b){a.container_mousedown(b)}),this.container.bind("mouseup.chosen",function(b){a.container_mouseup(b)}),this.container.bind("mouseenter.chosen",function(b){a.mouse_enter(b)}),this.container.bind("mouseleave.chosen",function(b){a.mouse_leave(b)}),this.search_results.bind("mouseup.chosen",function(b){a.search_results_mouseup(b)}),this.search_results.bind("mouseover.chosen",function(b){a.search_results_mouseover(b)}),this.search_results.bind("mouseout.chosen",function(b){a.search_results_mouseout(b)}),this.search_results.bind("mousewheel.chosen DOMMouseScroll.chosen",function(b){a.search_results_mousewheel(b)}),this.search_results.bind("touchstart.chosen",function(b){a.search_results_touchstart(b)}),this.search_results.bind("touchmove.chosen",function(b){a.search_results_touchmove(b)}),this.search_results.bind("touchend.chosen",function(b){a.search_results_touchend(b)}),this.form_field_jq.bind("chosen:updated.chosen",function(b){a.results_update_field(b)}),this.form_field_jq.bind("chosen:activate.chosen",function(b){a.activate_field(b)}),this.form_field_jq.bind("chosen:open.chosen",function(b){a.container_mousedown(b)}),this.form_field_jq.bind("chosen:close.chosen",function(b){a.input_blur(b)}),this.search_field.bind("blur.chosen",function(b){a.input_blur(b)}),this.search_field.bind("keyup.chosen",function(b){a.keyup_checker(b)}),this.search_field.bind("keydown.chosen",function(b){a.keydown_checker(b)}),this.search_field.bind("focus.chosen",function(b){a.input_focus(b)}),this.search_field.bind("cut.chosen",function(b){a.clipboard_event_checker(b)}),this.search_field.bind("paste.chosen",function(b){a.clipboard_event_checker(b)}),this.is_multiple?this.search_choices.bind("click.chosen",function(b){a.choices_click(b)}):this.container.bind("click.chosen",function(a){a.preventDefault()})},Chosen.prototype.destroy=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.search_field[0].tabIndex&&(this.form_field_jq[0].tabIndex=this.search_field[0].tabIndex),this.container.remove(),this.form_field_jq.removeData("chosen"),this.form_field_jq.show()},Chosen.prototype.search_field_disabled=function(){return this.is_disabled=this.form_field_jq[0].disabled,this.is_disabled?(this.container.addClass("chosen-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus.chosen",this.activate_action),this.close_field()):(this.container.removeClass("chosen-disabled"),this.search_field[0].disabled=!1,this.is_multiple?void 0:this.selected_item.bind("focus.chosen",this.activate_action))},Chosen.prototype.container_mousedown=function(b){return this.is_disabled||(b&&"mousedown"===b.type&&!this.results_showing&&b.preventDefault(),null!=b&&a(b.target).hasClass("search-choice-close"))?void 0:(this.active_field?this.is_multiple||!b||a(b.target)[0]!==this.selected_item[0]&&!a(b.target).parents("a.chosen-single").length||(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(this.container[0].ownerDocument).bind("click.chosen",this.click_test_action),this.results_show()),this.activate_field())},Chosen.prototype.container_mouseup=function(a){return"ABBR"!==a.target.nodeName||this.is_disabled?void 0:this.results_reset(a)},Chosen.prototype.search_results_mousewheel=function(a){var b;return a.originalEvent&&(b=-a.originalEvent.wheelDelta||a.originalEvent.detail),null!=b?(a.preventDefault(),"DOMMouseScroll"===a.type&&(b=40*b),this.search_results.scrollTop(b+this.search_results.scrollTop())):void 0},Chosen.prototype.blur_test=function(){return!this.active_field&&this.container.hasClass("chosen-container-active")?this.close_field():void 0},Chosen.prototype.close_field=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chosen-container-active"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},Chosen.prototype.activate_field=function(){return this.container.addClass("chosen-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},Chosen.prototype.test_active_click=function(b){var c;return c=a(b.target).closest(".chosen-container"),c.length&&this.container[0]===c[0]?this.active_field=!0:this.close_field()},Chosen.prototype.results_build=function(){return this.parsing=!0,this.selected_option_count=null,this.results_data=SelectParser.select_to_array(this.form_field),this.is_multiple?this.search_choices.find("li.search-choice").remove():this.is_multiple||(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?(this.search_field[0].readOnly=!0,this.container.addClass("chosen-container-single-nosearch")):(this.search_field[0].readOnly=!1,this.container.removeClass("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1},Chosen.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){if(this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight(),b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(f>c)return this.search_results.scrollTop(c)}},Chosen.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},Chosen.prototype.results_show=function(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.container.addClass("chosen-with-drop"),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.search_field.val()),this.winnow_results(),this.form_field_jq.trigger("chosen:showing_dropdown",{chosen:this}))},Chosen.prototype.update_results_content=function(a){return this.search_results.html(a)},Chosen.prototype.results_hide=function(){return this.results_showing&&(this.result_clear_highlight(),this.container.removeClass("chosen-with-drop"),this.form_field_jq.trigger("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1},Chosen.prototype.set_tab_index=function(){var a;return this.form_field.tabIndex?(a=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field[0].tabIndex=a):void 0},Chosen.prototype.set_label_behavior=function(){var b=this;return this.form_field_label=this.form_field_jq.parents("label"),!this.form_field_label.length&&this.form_field.id.length&&(this.form_field_label=a("label[for='"+this.form_field.id+"']")),this.form_field_label.length>0?this.form_field_label.bind("click.chosen",function(a){return b.is_multiple?b.container_mousedown(a):b.activate_field()}):void 0},Chosen.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices_count()<1&&!this.active_field?(this.search_field.val(this.default_text),this.search_field.addClass("default")):(this.search_field.val(""),this.search_field.removeClass("default"))},Chosen.prototype.search_results_mouseup=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c.length?(this.result_highlight=c,this.result_select(b),this.search_field.focus()):void 0},Chosen.prototype.search_results_mouseover=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c?this.result_do_highlight(c):void 0},Chosen.prototype.search_results_mouseout=function(b){return a(b.target).hasClass("active-result")?this.result_clear_highlight():void 0},Chosen.prototype.choice_build=function(b){var c,d,e=this;return c=a(" ",{"class":"search-choice"}).html(""+b.html+" "),b.disabled?c.addClass("search-choice-disabled"):(d=a(" ",{"class":"search-choice-close","data-option-array-index":b.array_index}),d.bind("click.chosen",function(a){return e.choice_destroy_link_click(a)}),c.append(d)),this.search_container.before(c)},Chosen.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),b.stopPropagation(),this.is_disabled?void 0:this.choice_destroy(a(b.target))},Chosen.prototype.choice_destroy=function(a){return this.result_deselect(a[0].getAttribute("data-option-array-index"))?(this.show_search_field_default(),this.is_multiple&&this.choices_count()>0&&this.search_field.val().length<1&&this.results_hide(),a.parents("li").first().remove(),this.search_field_scale()):void 0},Chosen.prototype.results_reset=function(){return this.reset_single_select_options(),this.form_field.options[0].selected=!0,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),this.form_field_jq.trigger("change"),this.active_field?this.results_hide():void 0},Chosen.prototype.results_reset_cleanup=function(){return this.current_selectedIndex=this.form_field.selectedIndex,this.selected_item.find("abbr").remove()},Chosen.prototype.result_select=function(a){var b,c;return this.result_highlight?(b=this.result_highlight,this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?b.removeClass("active-result"):this.reset_single_select_options(),c=this.results_data[b[0].getAttribute("data-option-array-index")],c.selected=!0,this.form_field.options[c.options_index].selected=!0,this.selected_option_count=null,this.is_multiple?this.choice_build(c):this.single_set_selected_text(c.text),(a.metaKey||a.ctrlKey)&&this.is_multiple||this.results_hide(),this.search_field.val(""),(this.is_multiple||this.form_field.selectedIndex!==this.current_selectedIndex)&&this.form_field_jq.trigger("change",{selected:this.form_field.options[c.options_index].value}),this.current_selectedIndex=this.form_field.selectedIndex,this.search_field_scale())):void 0},Chosen.prototype.single_set_selected_text=function(a){return null==a&&(a=this.default_text),a===this.default_text?this.selected_item.addClass("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClass("chosen-default")),this.selected_item.find("span").text(a)},Chosen.prototype.result_deselect=function(a){var b;return b=this.results_data[a],this.form_field.options[b.options_index].disabled?!1:(b.selected=!1,this.form_field.options[b.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),this.form_field_jq.trigger("change",{deselected:this.form_field.options[b.options_index].value}),this.search_field_scale(),!0)},Chosen.prototype.single_deselect_control_build=function(){return this.allow_single_deselect?(this.selected_item.find("abbr").length||this.selected_item.find("span").first().after(' '),this.selected_item.addClass("chosen-single-with-deselect")):void 0},Chosen.prototype.get_search_text=function(){return this.search_field.val()===this.default_text?"":a("
").text(a.trim(this.search_field.val())).html()},Chosen.prototype.winnow_results_set_highlight=function(){var a,b;return b=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),a=b.length?b.first():this.search_results.find(".active-result").first(),null!=a?this.result_do_highlight(a):void 0},Chosen.prototype.no_results=function(b){var c;return c=a(''+this.results_none_found+' " " '),c.find("span").first().html(b),this.search_results.append(c),this.form_field_jq.trigger("chosen:no_results",{chosen:this})},Chosen.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},Chosen.prototype.keydown_arrow=function(){var a;return this.results_showing&&this.result_highlight?(a=this.result_highlight.nextAll("li.active-result").first())?this.result_do_highlight(a):void 0:this.results_show()},Chosen.prototype.keyup_arrow=function(){var a;return this.results_showing||this.is_multiple?this.result_highlight?(a=this.result_highlight.prevAll("li.active-result"),a.length?this.result_do_highlight(a.first()):(this.choices_count()>0&&this.results_hide(),this.result_clear_highlight())):void 0:this.results_show()},Chosen.prototype.keydown_backstroke=function(){var a;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(a=this.search_container.siblings("li.search-choice").last(),a.length&&!a.hasClass("search-choice-disabled")?(this.pending_backstroke=a,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")):void 0)},Chosen.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},Chosen.prototype.keydown_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),8!==b&&this.pending_backstroke&&this.clear_backstroke(),b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:a.preventDefault(),this.keydown_arrow()}},Chosen.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){for(d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"],i=0,j=g.length;j>i;i++)e=g[i],f+=e+":"+this.search_field.css(e)+";";return b=a("
",{style:f}),b.text(this.search_field.val()),a("body").append(b),h=b.width()+25,b.remove(),c=this.container.outerWidth(),h>c-10&&(h=c-10),this.search_field.css({width:h+"px"})}},Chosen}(AbstractChosen)}.call(this);
// source --> https://manonc.fr/wp-content/plugins/woo-product-filter/modules/woofilters/js/chosen.order.jquery.min.js?ver=1.3.9
/* Chosen Order v1.2.1 | (c) 2013 by Tristan Jahier, http://tristan-jahier.fr */
(function(){var a,b,c,d=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1},e={}.hasOwnProperty,f=function(a,b){function c(){this.constructor=a}for(var d in b)e.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};b=function(){function a(){}var b;return b={invalid_select_element:"ChosenOrder::{{function}}: first argument must be a valid HTML Multiple Select element that has been Chosenified!",invalid_selection_array:"ChosenOrder::{{function}}: second argument must be an Array!",unreachable_chosen_container:'ChosenOrder::{{function}}: could not find the Chosen UI container! To solve the problem, try adding an "id" attribute to your element.',ordering_unselected_option:"ChosenOrder::{{function}}: ignoring option '{{option}}' which is not selected. Set optional parameter \"force\" to 'true' to get the ordered selection forced first."},a.insertAt=function(a,b,c){return c.insertBefore(a,c.children[b].nextSibling)},a.getFlattenedOptionsAndGroups=function(a){var b,c,d,e,f,g,h,i,j;for(d=Array.prototype.filter.call(a.childNodes,function(a){var b;return"OPTION"===(b=a.nodeName.toUpperCase())||"OPTGROUP"===b}),b=[],g=0,i=d.length;i>g;g++)if(c=d[g],b.push(c),"OPTGROUP"===c.nodeName.toUpperCase())for(f=Array.prototype.filter.call(c.childNodes,function(a){return"OPTION"===a.nodeName.toUpperCase()}),h=0,j=f.length;j>h;h++)e=f[h],b.push(e);return b},a.isValidMultipleSelectElement=function(a){return null!==a&&"undefined"!=typeof a&&"SELECT"===a.nodeName&&a.multiple},a.getChosenUIContainer=function(a){return""!==a.id?document.getElementById(a.id.replace(/-/g,"_")+"_chosen"):this.searchChosenUIContainer(a)},a.isChosenified=function(a){return null!=this.getChosenUIContainer(a)},a.forceSelection=function(a,b){var c,e,f,g;for(f=this.getFlattenedOptionsAndGroups(a),c=0;c=0?(e.selected=!0,e.setAttribute("selected","")):(e.selected=!1,e.removeAttribute("selected")),c++;return this.triggerEvent(a,"chosen:updated")},a.getSelectionOrder=function(a){var c,d,e,f,g,h,i,j,k,l;if(null!=this.getDOMElement&&(a=this.getDOMElement(a)),i=[],!this.isValidMultipleSelectElement(a))return console.error(b.invalid_select_element.replace("{{function}}","getSelectionOrder")),i;if(d=this.getChosenUIContainer(a),null==d)return console.error(b.unreachable_chosen_container.replace("{{function}}","getSelectionOrder")),i;for(c=d.querySelectorAll(".search-choice"),h=this.getFlattenedOptionsAndGroups(a),k=0,l=c.length;l>k;k++)f=c[k],e=f.querySelectorAll(".search-choice-close")[0],null!=e&&(j=e.getAttribute(this.relAttributeName)),g=h[j],i.push(g.value);return i},a.setSelectionOrder=function(a,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;if(null!=this.getDOMElement&&(a=this.getDOMElement(a)),!this.isValidMultipleSelectElement(a))return void console.error(b.invalid_select_element.replace("{{function}}","setSelectionOrder"));if(g=this.getChosenUIContainer(a),null==g)return void console.error(b.unreachable_chosen_container.replace("{{function}}","setSelectionOrder"));if(c instanceof Array){for(c=c.map(Function.prototype.call,String.prototype.trim),m=this.getFlattenedOptionsAndGroups(a),null!=d&&d===!0&&this.forceSelection(a,c),t=[],h=p=0,r=c.length;r>p;h=++p){for(k=c[h],n=null,i=q=0,s=m.length;s>q;i=++q)j=m[i],j.value===k&&(n=i);f=g.querySelectorAll(".search-choice"),o=this.relAttributeName,l=Array.prototype.filter.call(f,function(a){return null!=a.querySelector("a.search-choice-close["+o+'="'+n+'"]')})[0],null!=l?(e=g.querySelector("ul.chosen-choices"),t.push(this.insertAt(l,h,g.querySelector("ul.chosen-choices")))):console.warn(b.ordering_unselected_option.replace("{{function}}","setSelectionOrder").replace("{{option}}",k))}return t}return console.error(b.invalid_selection_array.replace("{{function}}","setSelectionOrder"))},a}(),a=jQuery,a.fn.extend({getSelectionOrder:function(){return ChosenOrder.getSelectionOrder(this)},setSelectionOrder:function(a,b){return ChosenOrder.setSelectionOrder(this,a,b)}}),this.ChosenOrder=function(b){function d(){return c=d.__super__.constructor.apply(this,arguments)}return f(d,b),d.relAttributeName="data-option-array-index",d.isjQueryObject=function(a){return"undefined"!=typeof jQuery&&null!==jQuery&&a instanceof jQuery},d.getDOMElement=function(a){return this.isjQueryObject(a)?a.get(0):a},d.searchChosenUIContainer=function(b){return null!=a(b).data("chosen")?a(b).data("chosen").container[0]:a(b).next(".chosen-container.chosen-container-multi").get(0)},d.triggerEvent=function(b,c){return a(b).trigger(c)},d}(b)}).call(this);
// source --> https://manonc.fr/wp-content/plugins/woo-product-filter/modules/woofilters/js/frontend.woofilters.js?ver=1.3.9
(function ($, app) {
"use strict";
function WpfFrontendPage() {
this.$obj = this;
this.noWoo = this.$obj.checkNoWooPage();
return this.$obj;
}
WpfFrontendPage.prototype.init = (function () {
var _thisObj = this.$obj;
_thisObj.isAdminPreview = jQuery('#wpfFiltersEditForm').length > 0;
_thisObj.checkForceFilters();
_thisObj.eventsPriceFilter();
_thisObj.disableLeerOptions();
_thisObj.eventsFrontend();
_thisObj.changeSlugByUrl();
_thisObj.runCustomJs();
_thisObj.addCustomCss();
_thisObj.chageRangeFieldWidth();
_thisObj.hideFiltersLoader();
_thisObj.addSpecificPluginActions();
});
WpfFrontendPage.prototype.checkForceFilters = (function() {
var forceShowFilter = jQuery('.wpfMainWrapper[data-force="1"]');
if (!forceShowFilter.length) return;
jQuery('.wpfMainWrapper').each(function () {
var wrapper = jQuery(this),
forceShowCurrent = wrapper.attr('data-force');
if (!forceShowCurrent){
wrapper.remove();
if (wrapper.closest('.WpfWoofiltersWidget').length) {
wrapper.closest('.WpfWoofiltersWidget').remove();
}
}
});
});
WpfFrontendPage.prototype.showFiltersLoader = (function() {
jQuery('.wpfMainWrapper').each(function () {
var wrapper = jQuery(this);
wrapper.css('position','relative');
if (!wrapper.find('.wpfLoaderLayout').length){
jQuery('
').addClass('wpfLoaderLayout').appendTo(wrapper);
wrapper.find('.wpfLoaderLayout').append(' ');
}
wrapper.find('.wpfLoaderLayout').show();
});
});
WpfFrontendPage.prototype.hideFiltersLoader = (function() {
jQuery('.wpfMainWrapper').each(function () {
var wrapper = jQuery(this);
hideFilterLoader(wrapper);
});
});
WpfFrontendPage.prototype.runCustomJs = (function () {
var _thisObj = this.$obj;
jQuery('.wpfMainWrapper').each(function () {
var wrapper = jQuery(this),
jsCodeStr = '',
settings = _thisObj.getFilterMainSettings(wrapper);
if(settings){
settings = settings.settings;
jsCodeStr = settings.js_editor;
}
if(jsCodeStr.length > 0){
try {
eval(jsCodeStr);
}catch(e) {
console.log(e);
}
}
});
});
WpfFrontendPage.prototype.addCustomCss = (function () {
var _thisObj = this.$obj,
cssCodeStr = '';
jQuery('style#wpfCustomCss').remove();
jQuery('.wpfMainWrapper').each(function () {
var wrapper = jQuery(this),
customCss = jQuery('style#wpfCustomCss-'+wrapper.attr('data-viewid'));
if(customCss.length) {
cssCodeStr += customCss.html();
customCss.remove();
}
});
if(cssCodeStr.length > 0){
jQuery('').appendTo('head');
}
});
WpfFrontendPage.prototype.chageRangeFieldWidth = (function () {
var _thisObj = this.$obj;
jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"]').each(function () {
var filter = jQuery(this),
input1 = filter.find('#wpfMinPrice'),
input2 = filter.find('#wpfMaxPrice'),
fontSize1 = input1.css('font-size'),
fontSize2 = input2.css('font-size'),
buffer1 = filter.find('.input-buffer-min'),
buffer2 = filter.find('.input-buffer-max');
if(fontSize1) buffer1.css('font-size', fontSize1);
if(fontSize2) buffer2.css('font-size', fontSize2);
jQuery(buffer1).text(input1.val());
jQuery(buffer2).text(input2.val());
if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
jQuery(input1).width(buffer1.width()+20);
jQuery(input2).width(buffer2.width()+20);
} else {
jQuery(input1).width(buffer1.width()+10);
jQuery(input2).width(buffer2.width()+10);
}
});
});
WpfFrontendPage.prototype.eventsPriceFilter = (function () {
var _thisObj = this.$obj;
jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"]').each(function () {
_thisObj.initDefaultSlider(jQuery(this));
});
//change price filters
jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"]').on('wpfPriceChange', function(event){
var filter = jQuery(this),
mainWrapper = filter.closest('.wpfMainWrapper');
mainWrapper.find('.wpfFilterWrapper[data-filter-type="wpfPriceRange"] input').prop('checked', false);
mainWrapper.find('.wpfFilterWrapper[data-filter-type="wpfPriceRange"] select')
.val(mainWrapper.find('.wpfFilterWrapper[data-filter-type="wpfPriceRange"] select option:first').val());
filter.removeClass('wpfNotActive');
mainWrapper.find('.wpfFilterWrapper[data-filter-type="wpfPriceRange"]').addClass('wpfNotActive');
});
//change price range
jQuery('.wpfFilterWrapper[data-filter-type="wpfPriceRange"] input, .wpfFilterWrapper[data-filter-type="wpfPriceRange"] select').on('change', function(e){
e.preventDefault();
jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"]').addClass('wpfNotActive');
});
});
WpfFrontendPage.prototype.initDefaultSlider = (function (filter, type) {
var _thisObj = this.$obj,
wrapper = filter.closest('.wpfMainWrapper'),
filterType = typeof type !== 'undefined' ? type : 'price',
getAttr = filter.data('get-attribute'),
minInputId = '#wpfMinPrice',
maxInputId = '#wpfMaxPrice',
triggerName = 'wpfPriceChange';
if (filterType === 'attr') {
minInputId = '#wpfMinAttrNum';
maxInputId = '#wpfMaxAttrNum';
triggerName = 'wpfAttrSliderChange';
}
var minSelector = filter.closest('.wpfFilterWrapper').find(minInputId),
maxSelector = filter.closest('.wpfFilterWrapper').find(maxInputId),
wpfDataStep = filter.closest('.wpfFilterWrapper').find('#wpfDataStep').val()
if (wpfDataStep == '0.001') {
wpfDataStep = '0.00000001';
}
wpfDataStep = Number(wpfDataStep);
var valMin = parseFloat(minSelector.attr('min')),
valMax = parseFloat(maxSelector.attr('max')),
curUrl = window.location.href,
urlParams = _thisObj.findGetParameter(curUrl),
minPriceGetParams = urlParams.min_price ? parseFloat(urlParams.min_price) : valMin,
maxPriceGetParams = urlParams.max_price ? parseFloat(urlParams.max_price) : valMax;
if (filterType === 'attr') {
if (urlParams[getAttr]) {
var idsAnd = urlParams[getAttr].split(','),
idsOr = urlParams[getAttr].split('|'),
isAnd = idsAnd.length > idsOr.length;
var filterTypeValues = isAnd ? idsAnd : idsOr;
}
minPriceGetParams = urlParams[getAttr] ? parseFloat(filterTypeValues[0]) : valMin;
maxPriceGetParams = urlParams[getAttr] ? parseFloat(filterTypeValues.pop()) : valMax;
}
var sliderWrapper = filter.find("#wpfSliderRange"),
autoFilteringEnable = (wrapper.find('.wpfFilterButton').length == 0),
skin = filter.attr('data-price-skin');
if(skin === 'default'){
sliderWrapper.slider({
range: true,
orientation: "horizontal",
min: valMin,
max: valMax,
step: wpfDataStep,
values: [minPriceGetParams, maxPriceGetParams],
slide: function (event, ui) {
minSelector.val(ui.values[0]);
maxSelector.val(ui.values[1]);
filter.trigger(triggerName);
},
start: function () {
filter.trigger(triggerName);
},
stop: function () {
if(autoFilteringEnable){
_thisObj.filtering(wrapper);
}
}
});
minSelector.val(sliderWrapper.slider("values", 0));
maxSelector.val(sliderWrapper.slider("values", 1));
}else if(skin === 'skin1'){
var sliderWrapper = jQuery("#wpfSlider");
sliderWrapper.attr('value', minPriceGetParams + ';' + maxPriceGetParams);
var countCall = 0,
timeOut = 0;
setTimeout(function() {
sliderWrapper.slideregor({
from: valMin,
to: valMax,
limits: true,
step: wpfDataStep,
skin: "round",
onstatechange : function(value) {
countCall++;
if(countCall > 2){
var _this = this,
values = _this.getValue().split(';');
minSelector.val(values[0]);
maxSelector.val(values[1]);
if(!sliderWrapper.closest('.wpfFilterWrapper').hasClass('wpfNotActiveSlider')){
sliderWrapper.closest('.wpfFilterWrapper').removeClass('wpfNotActive');
clearTimeout(timeOut);
timeOut = setTimeout(function(){
filter.trigger(triggerName);
if(ajaxModeEnable){
_thisObj.filtering(wrapper);
}
},1000);
}
}
}
});
}, 200);
}
});
// add/remove get query param
WpfFrontendPage.prototype.QStringWork = (function ($attr, $value, $noWooPage, $filterWrapper, $type) {
$noWooPage = false;
if (window.wpfAdminPage) {
$noWooPage = true;
}
if($type === 'change'){
var curUrl = changeUrl($attr, $value, $noWooPage, $filterWrapper );
$filterWrapper.attr('data-hide-url', decodeURI(curUrl));
}else if($type === 'remove'){
var curUrl = removeQString($attr, $noWooPage, $filterWrapper);
$filterWrapper.attr('data-hide-url', decodeURI(curUrl));
}
});
WpfFrontendPage.prototype.eventChangeFilter = (function (e) {
var _thisObj = this.$obj,
_this = jQuery(e.target),
mainWrapper = _this.closest('.wpfMainWrapper'),
settings = _thisObj.getFilterMainSettings(mainWrapper);
_this.closest('.wpfFilterWrapper').removeClass('wpfNotActive');
if(typeof(_thisObj.eventChangeFilterPro) == 'function') {
_thisObj.eventChangeFilterPro(_this, settings);
}
if(mainWrapper.find('.wpfFilterButton').length == 0) {
_thisObj.filtering(mainWrapper);
}
});
WpfFrontendPage.prototype.eventsFrontend = (function () {
var _thisObj = this.$obj;
jQuery('.wpfMainWrapper').find('select[multiple]').each(function(){
var select = jQuery(this),
selectAll = select.attr('data-placeholder'),
search = JSON.parse(select.attr('data-search'));
select.multiselect({search: search.show, columns: 1, placeholder: selectAll ? selectAll : 'Select options', optionAttributes: ['style','data-term-id'], searchOptions: {'default': search.placeholder}});
});
if(jQuery('.wpfFilterWrapper[data-filter-type="wpfSortBy"]').length == 0) {
jQuery('.woocommerce-ordering').css('display', 'block');
}
//if no enabled filters hide all html
if(jQuery('.wpfFilterWrapper').length < 1){
jQuery('.wpfMainWrapper').addClass('wpfHidden');
}
//Start filtering
jQuery('.wpfFilterButton').on('click', function(e){
e.preventDefault();
_thisObj.filtering(jQuery(this).closest('.wpfMainWrapper'));
});
//Clear filters
jQuery('.wpfClearButton').on('click', function(e){
e.preventDefault();
var $filterWrapper = jQuery(this).closest('.wpfMainWrapper'),
settings = _thisObj.getFilterMainSettings($filterWrapper),
resetAllFilters = typeof settings.settings.reset_all_filters !== 'undefined' ? settings.settings.reset_all_filters : 0;
if (resetAllFilters !== '0') {
jQuery('.wpfMainWrapper').each(function(){
_thisObj.clearFilters(jQuery(this).find('.wpfFilterWrapper'), true);
});
} else {
_thisObj.clearFilters($filterWrapper.find('.wpfFilterWrapper'), true);
}
_thisObj.filtering($filterWrapper, true);
});
//price range choose only one checkbox
jQuery('.wpfFilterWrapper[data-filter-type="wpfPriceRange"] .wpfFilterContent input').on('change', function (e) {
e.preventDefault();
var input = jQuery(this),
inputs = input.closest('.wpfFilterWrapper').find('input');
if(input.is(":checked")){
inputs.prop('checked', false);
input.prop('checked', true);
}
});
//category/brand list choose only one checkbox
jQuery('.wpfFilterWrapper[data-filter-type="wpfCategory"], .wpfFilterWrapper[data-filter-type="wpfPerfectBrand"]').each(function() {
var categoryFilter = jQuery(this),
displayType = categoryFilter.data('display-type'),
categoryMulti = displayType == 'multi';
categoryFilter.find('.wpfFilterContent input').on('change', function (e) {
e.preventDefault();
var input = jQuery(this);
if(categoryMulti) {
var mainWrapper = input.closest('.wpfMainWrapper'),
filterWrapper = input.closest('.wpfFilterWrapper'),
expandSelectedToChild = _thisObj.getFilterParam('f_multi_extend_parent_select', mainWrapper, filterWrapper);
if(expandSelectedToChild && input.is(':checked')) {
input.closest('li').find('ul input').prop('checked', true);
}
if (expandSelectedToChild && ! input.is(':checked') ) {
input.closest('li').find('ul input').prop('checked', false);
}
}
});
});
//rating choose only one checkbox
jQuery('.wpfFilterWrapper[data-filter-type="wpfRating"] .wpfFilterContent input').on('change', function (e) {
e.preventDefault();
var input = jQuery(this),
inputs = input.closest('.wpfFilterWrapper').find('input');
if(input.is(":checked")){
inputs.prop('checked', false);
input.prop('checked', true);
}
});
//after change input or dropdown make this filter active
//check if ajax mode enable and filtering on filter elements change
jQuery('.wpfFilterWrapper select, .wpfFilterWrapper input:not(.passiveFilter)').on('change', function (e) {
e.preventDefault();
var isExeptionCase = _thisObj.checkExeptionCasesBeforeFiltering(this);
if (!isExeptionCase) {
setTimeout(function() {
_thisObj.eventChangeFilter(e);
}, 100);
}
});
//after change input or dropdown make this filter active
jQuery('.wpfFilterWrapper input:not(.passiveFilter)').on('change', function (e) {
e.preventDefault();
//check if input change move to top
_thisObj.moveCheckedToTop(jQuery(this));
// check multy or single input (radio or checkbox)
_thisObj.detectSingleCheckbox(jQuery(this))
});
//search field work
jQuery('.wpfFilterWrapper .wpfSearchFieldsFilter').on('keyup', function (e) {
var _this = jQuery(this),
wrapper = _this.closest('.wpfFilterWrapper'),
searchVal = _this.val().toLowerCase();
wrapper.find('.wpfFilterContent li:not(.wpfShowFewerWrapper)').filter(function() {
if (jQuery(this).find('.wpfValue').text().toLowerCase().indexOf(searchVal) > -1) {
jQuery(this).removeClass('wpfSearchHidden');
} else {
jQuery(this).addClass('wpfSearchHidden');
}
});
if(typeof(_thisObj.initShowMore) == 'function') {
_thisObj.initShowMore(wrapper.find('.wpfFilterVerScroll'));
}
});
jQuery('.wpfFilterWrapper .wpfSearchFieldsFilter').on('change', function (e) {
jQuery(this).closest('.wpfFilterWrapper').find('.wpfFilterContent li.wpfSearchHidden .wpfCheckbox input').prop('checked', false);
});
//uncheck one slug
jQuery('body').off('click', '.wpfSlugDelete').on('click', '.wpfSlugDelete', function(){
var _this = jQuery(this),
wrapper = _this.closest('.wpfSlug'),
filterType = wrapper.attr('data-filter-type'),
filterAttr = wrapper.attr('data-get-attribute'),
filterWrapper = false;
jQuery('.wpfFilterWrapper[data-filter-type="'+filterType+'"][data-get-attribute="'+filterAttr+'"]').each(function(){
var $this = jQuery(this),
filterType = $this.attr("data-filter-type");
if (filterType == 'wpfPrice' || filterType == 'wpfPriceRange') {
_thisObj.clearFilters($("[data-filter-type='wpfPrice']:not(.wpfSelectedParameter)"));
_thisObj.clearFilters($("[data-filter-type='wpfPriceRange']:not(.wpfSelectedParameter)"));
} else {
_thisObj.clearFilters($this);
}
if(filterWrapper == false) {
filterWrapper = $this.closest('.wpfMainWrapper');
}
});
if(filterWrapper != false) {
_thisObj.filtering(filterWrapper);
}
});
jQuery('body').off('click', '.wpfFilterTitle').on('click', '.wpfFilterTitle', function(e){
e.preventDefault();
var _this = jQuery(this),
wrapper = _this.closest('.wpfMainWrapper'),
settings = _thisObj.getFilterMainSettings(wrapper),
content = _this.closest('.wpfFilterWrapper').find('.wpfFilterContent'),
toggle = _this.find('i.wpfTitleToggle'),
isPlus = toggle.hasClass('fa-plus');
if (settings.settings.hide_filter_icon !== '0') {
if (isPlus) {
_thisObj.openFilterToggle(toggle, content, true);
} else {
_thisObj.closeFilterToggle(toggle, content, true);
}
}
});
jQuery('.wpfMainWrapper .wpfFilterWrapper').each(function() {
var _this = jQuery(this),
wrapper = _this.closest('.wpfMainWrapper'),
settings = _thisObj.getFilterMainSettings(wrapper),
isMobile = false,
screenSize = jQuery(window).width();
if (settings.settings !== undefined) {
var isMobileBreakpoin = settings.settings.desctop_mobile_breakpoint_switcher,
mobileBreakpoinWidth = settings.settings.desctop_mobile_breakpoint_width,
mobileBreakpoinWidth = settings.settings.desctop_mobile_breakpoint_width,
displayFor = settings.settings.display_for,
filterWidthDesktop = settings.settings.filter_width,
filterWidthDesktopUnit = settings.settings.filter_width_in,
filterWidthMobile = settings.settings.filter_width_mobile,
filterWidthMobileUnit = settings.settings.filter_width_in_mobile,
filterBlockWidthDesktop = settings.settings.filter_block_width,
filterBlockWidthDesktopUnit = settings.settings.filter_block_width_in,
filterBlockWidthMobile = settings.settings.filter_block_width_mobile,
filterBlockWidthMobileUnit = settings.settings.filter_block_width_in_mobile;
if (isMobileBreakpoin && '0' !== isMobileBreakpoin && mobileBreakpoinWidth && '0' !== mobileBreakpoinWidth) {
if (screenSize <= mobileBreakpoinWidth) {
isMobile = true;
}
// "Filter Width" and "Filter Block Width" options
if (isMobile && filterBlockWidthMobile != '0') {
wrapper.css('width', filterWidthMobile+filterWidthMobileUnit);
_this.css('width', filterBlockWidthMobile+filterBlockWidthMobileUnit);
if (filterBlockWidthMobile+filterBlockWidthMobileUnit != '100%') {
_this.css('float', 'left');
}
} else if (!isMobile && filterBlockWidthDesktop != '0') {
wrapper.css('width', filterWidthDesktop+filterWidthDesktopUnit);
_this.css('width', filterBlockWidthDesktop+filterBlockWidthDesktopUnit);
if (filterBlockWidthDesktop+filterBlockWidthDesktopUnit != '100%') {
_this.css('float', 'left');
}
}
// "Display filter on" option
if (isMobile && displayFor == 'desktop') {
wrapper.hide();
} else if (!isMobile && displayFor == 'mobile') {
wrapper.hide();
}
// filters title
_this.find('.wpfFilterTitle[data-show-on-mobile]').each(function() {
jQuery(this).closest('.wpfFilterMainWrapper').find('wpfLoaderLayout').show();
var showDesctop = jQuery(this).data('show-on-desctop'),
showMobile = jQuery(this).data('show-on-mobile'),
content = jQuery(this).closest('.wpfFilterWrapper').find('.wpfFilterContent'),
toggle = jQuery(this).closest('.wpfFilterWrapper').find('i.wpfTitleToggle'),
title = jQuery(this).find('.wfpTitle');
if (isMobile) {
if (showMobile == 'yes_open') {
_thisObj.openFilterToggle(toggle, content);
} else if(showMobile == 'yes_close') {
_thisObj.closeFilterToggle(toggle, content);
} else if(showMobile == 'no') {
_thisObj.openFilterToggle(toggle, content);
toggle.remove();
title.remove();
}
} else {
if (showDesctop == 'yes_open') {
_thisObj.openFilterToggle(toggle, content);
} else if(showDesctop == 'yes_close') {
_thisObj.closeFilterToggle(toggle, content);
} else if(showDesctop == 'no') {
_thisObj.openFilterToggle(toggle, content);
toggle.remove();
title.remove();
}
}
});
}
}
});
jQuery('body').off('click', '.wpfFilterWrapper .wpfBlockClear').on('click', '.wpfFilterWrapper .wpfBlockClear', function(){
var parent = jQuery(this).closest(".wpfFilterWrapper"),
parentAttr = parent.attr("data-filter-type");
if (parentAttr == 'wpfPrice' || parentAttr == 'wpfPriceRange') {
_thisObj.clearFilters($("[data-filter-type='wpfPrice']:not(.wpfSelectedParameter)"));
_thisObj.clearFilters($("[data-filter-type='wpfPriceRange']:not(.wpfSelectedParameter)"));
} else {
_thisObj.clearFilters(parent);
}
_thisObj.filtering(parent.closest('.wpfMainWrapper'));
});
jQuery('body').off('wpffiltering').on('wpffiltering', function () {
_thisObj.setPagination(1);
_thisObj.filtering();
_thisObj.setPagination(0);
});
//click on new pagination link with page number
jQuery('body').off('click', '.wpfNoWooPage .woocommerce-pagination .page-numbers').on('click', '.wpfNoWooPage .woocommerce-pagination .page-numbers', function (e) {
e.preventDefault();
var _this = jQuery(this),
paginationWrapper = _this.closest('.woocommerce-pagination'),
currentNumber = paginationWrapper.find('.current').text();
if(!_this.hasClass('next') && !_this.hasClass('prev') ){
var number = _this.text();
}else if(_this.hasClass('next')){
var number = parseInt(currentNumber) + 1;
}else if(_this.hasClass('prev')){
var number = (parseInt(currentNumber) - 1) < 1 ? parseInt(currentNumber) - 1 : 1;
}
var wrapper = jQuery('.wpfMainWrapper').first(),
$queryVars = wrapper.attr('data-settings');
try{
var settings = JSON.parse($queryVars);
}catch(e){
var settings = false;
}
if(settings){
settings.paged = number;
settings.pagination = 1;
wrapper.attr('data-settings', JSON.stringify(settings) );
}
// todo: testing for two+ filters on page
_thisObj.filtering( jQuery('.wpfMainWrapper') );
_thisObj.setPagination(0);
});
});
WpfFrontendPage.prototype.checkExeptionCasesBeforeFiltering = (function (filterInput) {
var isExeption = false;
// exeption when custom price do not set but input activated
if ( jQuery(filterInput).parent().hasClass('wpfPriceCheckboxCustom')) {
var customPriceWrapper = jQuery(filterInput).closest('li'),
customMin = customPriceWrapper.find('input[name=wpf_custom_min]').val(),
customMax = customPriceWrapper.find('input[name=wpf_custom_max]').val();
if (!customMin && !customMax) {
isExeption = true;
}
}
return isExeption;
});
WpfFrontendPage.prototype.detectSingleCheckbox = (function (checkedInput) {
var filterWrapper = checkedInput.closest('.wpfFilterWrapper'),
displayType = filterWrapper.data('display-type'),
filterType = filterWrapper.data('filter-type');
if (filterType == 'wpfCategory' || filterType == 'wpfPerfectBrand'|| filterType == 'wpfBrand') {
var isOne = displayType == 'list';
} else {
var isOne = displayType == 'radio';
}
if (isOne) {
var inputs = filterWrapper.find('input');
if (checkedInput.is(':checked')) {
inputs.prop('checked', false);
checkedInput.prop('checked', true);
}
}
});
WpfFrontendPage.prototype.moveCheckedToTop = (function (checkedInput) {
var _thisObj = this.$obj;
setTimeout(function() {
var checkboxWrapper = checkedInput.closest('li'),
checkboxesWrapper = checkedInput.closest('.wpfFilterVerScroll'),
mainWrapper = checkedInput.closest('.wpfMainWrapper'),
filterWrapper = checkedInput.closest('.wpfFilterWrapper'),
isHierarchical = filterWrapper.data('show-hierarchical'),
settings = _thisObj.getFilterMainSettings(mainWrapper);
if(settings && !isHierarchical) {
settings = settings.settings;
var checkedItemsTop = settings.checked_items_top === '1',
isExeptionCase = _thisObj.checkExeptionCasesBeforeFiltering(checkedInput);
if(checkedItemsTop && !isExeptionCase){
if (checkedInput.is(":checked")) {
checkboxesWrapper.prepend(checkboxWrapper);
} else {
checkboxesWrapper.append(checkboxWrapper);
}
}
}
}, 200);
});
WpfFrontendPage.prototype.closeFilterToggle = (function (toggle, content, isTimeout) {
toggle.removeClass('fa-minus');
toggle.addClass('fa-plus');
content.addClass('wpfBlockAnimated');
if (typeof isTimeout !== 'undefined' && isTimeout) {
setTimeout(function() {
if(content.hasClass('wpfBlockAnimated')) content.addClass('wpfHide');
}, 10);
} else {
if(content.hasClass('wpfBlockAnimated')) content.addClass('wpfHide');
}
});
WpfFrontendPage.prototype.openFilterToggle = (function (toggle, content, isTimeout) {
toggle.removeClass('fa-plus');
toggle.addClass('fa-minus');
content.removeClass('wpfHide');
if (typeof isTimeout !== 'undefined' && isTimeout) {
setTimeout(function() {
if(!content.hasClass('wpfHide')) content.removeClass('wpfBlockAnimated');
}, 400);
} else {
if(!content.hasClass('wpfHide')) content.removeClass('wpfBlockAnimated');
}
});
WpfFrontendPage.prototype.setPagination = (function (pagination) {
var wrapper = jQuery('.wpfMainWrapper').first(),
$queryVars = wrapper.attr('data-settings');
try{
var settings = JSON.parse($queryVars);
}catch(e){
var settings = false;
}
if(settings){
settings.pagination = pagination;
wrapper.attr('data-settings', JSON.stringify(settings) );
}
});
WpfFrontendPage.prototype.filtering = (function ($filterWrapper, clearAll) {
var _thisObj = this.$obj;
_thisObj.chageRangeFieldWidth();
if(_thisObj.isAdminPreview) return;
_thisObj.createOverlay();
if(typeof $filterWrapper == 'undefined' || $filterWrapper.length == 0) {
$filterWrapper = jQuery('.wpfMainWrapper').first();
}
var $filtersDataBackend = [],
$filtersDataFrontend = [],
noWooPage = _thisObj.noWoo;
$filterWrapper.find('.wpfFilterWrapper:not(.wpfNotActive), .wpfFilterWrapper.wpfPreselected').each(function () {
var $filter = jQuery(this),
filterType = $filter.attr('data-filter-type'),
filterName = $filter.attr('data-get-attribute'),
uniqId = $filter.attr('data-uniq-id'),
allSettings = _thisObj.getFilterOptionsByType($filter, filterType),
valueToPushBackend = {},
valueToPushFrontend = {},
logic = $filter.attr('data-query-logic');
if(typeof logic === 'undefined') {
logic = 'or';
}
var withChildren = $filter.attr('data-query-children');
if(typeof withChildren === 'undefined') {
withChildren = '1';
}
if (allSettings['backend'].length && typeof allSettings['backend'] !== 'undefined' || filterType === 'wpfSearchText') {
valueToPushBackend['id'] = filterType;
valueToPushBackend['uniqId'] = uniqId;
valueToPushBackend['logic'] = logic;
valueToPushBackend['children'] = withChildren;
valueToPushBackend['settings'] = allSettings['backend'];
valueToPushBackend['name'] = filterName;
$filtersDataBackend.push(valueToPushBackend);
}
valueToPushFrontend['id'] = filterType;
var logicDelimetrList = {
or: '|',
and: ',',
not_in: ';'
}
valueToPushFrontend['delim'] = logicDelimetrList[logic];
valueToPushFrontend['children'] = withChildren;
valueToPushFrontend['settings'] = allSettings['frontend'];
valueToPushFrontend['name'] = filterName;
$filtersDataFrontend.push(valueToPushFrontend);
});
_thisObj.changeUrlByFilterParams($filtersDataFrontend);
_thisObj.changeSlugByUrl();
_thisObj.QStringWork('wpf_reload', '', noWooPage, $filterWrapper, 'remove');
var settings = _thisObj.getFilterMainSettings($filterWrapper);
if(settings && settings.settings.enable_ajax !== '1'){
location.reload();
return;
}
//get paged params from html
var $queryVars = $filterWrapper.attr('data-settings'),
$queryVarsSettings = JSON.parse($queryVars),
$generalSettings = $filterWrapper.attr('data-filter-settings');
// find woocommerce product loop type ( shorcode, loop )
$queryVars = JSON.parse($queryVars);
var shortcode = jQuery('span[data-shortcode-attribute]'),
$shortcodeAttr = {};
if (shortcode.length) {
$shortcodeAttr = shortcode.data('shortcode-attribute');
$queryVars['posts_per_page'] = $shortcodeAttr['limit'];
$queryVars['wc_loop_type'] = 'shortcode';
$queryVars['paginate_type'] = 'shortcode';
$queryVars['paginate_base'] = 'product-page';
} else {
$queryVars['wc_loop_type'] = 'loop';
}
$queryVars = JSON.stringify($queryVars);
$shortcodeAttr = JSON.stringify($shortcodeAttr);
$generalSettings = JSON.parse($generalSettings);
var $filterSettings = {
'filter_recount' : $generalSettings['settings']['filter_recount'] && ($generalSettings['settings']['filter_recount'] == '1') ? true : false,
'filter_recount_price' : $generalSettings['settings']['filter_recount_price'] && ($generalSettings['settings']['filter_recount_price'] == '1') ? true : false,
'text_no_products' : $generalSettings['settings']['text_no_products'] ? $generalSettings['settings']['text_no_products'] : '',
'sort_by_title' : $filtersDataBackend.length && $generalSettings['settings']['sort_by_title'] && ($generalSettings['settings']['sort_by_title'] == '1') ? true : false,
'count_product_shop': $generalSettings['settings']['count_product_shop'] ? parseInt($generalSettings['settings']['count_product_shop']) : 0,
'f_multi_logic': $generalSettings['settings']['f_multi_logic'] ? $generalSettings['settings']['f_multi_logic'] : 'and',
'remove_actions': $generalSettings['settings']['remove_actions'] && ($generalSettings['settings']['remove_actions'] == '1') ? true : false,
'filtering_by_variations': $generalSettings['settings']['filtering_by_variations'] && ($generalSettings['settings']['filtering_by_variations'] == '1') ? true : false,
'display_product_variations': $generalSettings['settings']['display_product_variations'] && ($generalSettings['settings']['display_product_variations'] == '1') ? true : false,
'all_products_filtering': $generalSettings['settings']['all_products_filtering'] && ($generalSettings['settings']['all_products_filtering'] == '1') ? true : false,
'use_category_filtration': $generalSettings['settings']['use_category_filtration'] ? $generalSettings['settings']['use_category_filtration'] : 1
};
if($filterSettings['count_product_shop'] > 0) {
_thisObj.QStringWork('wpf_count', $filterSettings['count_product_shop'], noWooPage, $filterWrapper, 'change');
}
if($filterSettings['sort_by_title']) {
_thisObj.QStringWork('wpf_order', 'title', noWooPage, $filterWrapper, 'change');
}
if($filterSettings['filtering_by_variations']) {
_thisObj.QStringWork('wpf_fbv', 1, noWooPage, $filterWrapper, 'change');
}
if($filterSettings['display_product_variations']) {
_thisObj.QStringWork('wpf_dpv', 1, noWooPage, $filterWrapper, 'change');
}
if ($filterSettings['all_products_filtering'] && !clearAll) {
_thisObj.QStringWork('all_products_filtering', '1', noWooPage, $filterWrapper, 'change');
}
if ($filtersDataBackend.length === 0) {
_thisObj.QStringWork('all_products_filtering', '', noWooPage, $filterWrapper, 'remove');
}
if ($filterSettings['f_multi_logic'] !== 'and' && !clearAll) {
_thisObj.QStringWork('filter_tax_block_logic', $filterSettings['f_multi_logic'], noWooPage, $filterWrapper, 'change');
}
if ($filtersDataBackend.length === 0) {
_thisObj.QStringWork('filter_tax_block_logic', '', noWooPage, $filterWrapper, 'remove');
}
// we always start from first page after filtering
if ($queryVarsSettings['paginate_type'] == 'query' || $queryVarsSettings['paginate_type'] == 'shortcode') {
_thisObj.QStringWork($queryVarsSettings['paginate_base'], '', noWooPage, $filterWrapper, 'remove');
_thisObj.QStringWork('product-page', '', noWooPage, $filterWrapper, 'remove');
}
var $woocommerceSettings = {};
if(jQuery('.wpfFilterWrapper[data-filter-type="wpfSortBy"]').length == 0) {
var $wooCommerceSort = jQuery('.woocommerce-ordering select');
if($wooCommerceSort.length > 0) {
$woocommerceSettings['woocommercefSortBy'] = $wooCommerceSort.eq(0).val();
}
}
// event for custom javascript hook
var customEvent = document.createEvent('Event');
customEvent.initEvent('wpfAjaxStart', false, true);
document.dispatchEvent(customEvent);
//ajax call to server
_thisObj.currentLoadId = $filterWrapper.attr('id');
_thisObj.sendFiltersOptionsByAjax($filtersDataBackend, $queryVars, $filterSettings, $generalSettings, $woocommerceSettings, $shortcodeAttr);
});
WpfFrontendPage.prototype.createOverlay = (function () {
jQuery('#wpfOverlay').css({'display':'block'});
});
WpfFrontendPage.prototype.removeOverlay = (function () {
jQuery('#wpfOverlay').css({'display':'none'});
});
WpfFrontendPage.prototype.clearFilters = (function (filter, clearAll) {
var _thisObj = this.$obj,
noWooPage = _thisObj.noWoo,
clearAll = typeof clearAll == 'undefined' ? false : true;
(filter ? filter : jQuery('.wpfFilterWrapper')).each(function () {
var $filter = jQuery(this),
$filterWrapper = $filter.closest('.wpfMainWrapper'),
filterAttribute = $filter.attr('data-get-attribute'),
filterType = $filter.attr('data-display-type');
filterAttribute = filterAttribute.split(",");
var count = filterAttribute.length;
for(var i = 0; i < count; i++){
_thisObj.QStringWork(filterAttribute[i], '', noWooPage, $filterWrapper, 'remove');
}
if($filter.hasClass('wpfHidden')){
$filter.removeClass('wpfNotActive');
} else {
$filter.find('input').prop('checked', false);
if(filterType == 'mul_dropdown') {
$filter.find('select').val('');
$filter.find('select.jqmsLoaded').multiselect('reload');
} else if(filterType == 'text') {
$filter.find('input').val('');
} else {
// $filter.find('select option:first').attr('selected', true);
$filter.find("select").val($filter.find("select option:first").val());
}
$filter.addClass('wpfNotActive');
}
if($filter.attr('data-filter-type') === 'wpfPrice'){
var min = $filter.find('#wpfMinPrice').attr('min'),
max = $filter.find('#wpfMaxPrice').attr('max');
$filter.find('#wpfMinPrice').val(min);
$filter.find('#wpfMaxPrice').val(max);
jQuery( "#wpfSliderRange" ).slider( "option", "values", [ min, max ] );
}
if(typeof(_thisObj.clearFiltersPro) == 'function') {
_thisObj.clearFiltersPro($filter);
}
if(typeof(_thisObj.eventChangeFilterPro) == 'function') {
_thisObj.eventChangeFilterPro($filter);
}
if(clearAll) {
_thisObj.QStringWork('wpf_order', '', noWooPage, $filterWrapper, 'remove');
}
if(clearAll) {
_thisObj.QStringWork('all_products_filtering', '', noWooPage, $filterWrapper, 'remove');
}
});
});
WpfFrontendPage.prototype.getFilterMainSettings = (function ($selector) {
var settingsStr = $selector.attr('data-filter-settings');
try{
var settings = JSON.parse(settingsStr);
}catch(e){
var settings = false;
}
return settings;
});
WpfFrontendPage.prototype.getFilterParam = (function (paramSlug, mainWrapper, filterWrapper) {
var paramValue = null,
_thisObj = this.$obj,
mainSettings = _thisObj.getFilterMainSettings(mainWrapper),
filterOder = _thisObj.getFilterOrderInMainWrapper(paramSlug, mainWrapper, filterWrapper);
if (mainSettings.settings.filters.order && filterOder) {
var filtersOderList = JSON.parse(mainSettings.settings.filters.order),
filterParamList = filtersOderList[filterOder-1].settings;
if ( typeof filterParamList[paramSlug] !== undefined ) {
paramValue = filterParamList[paramSlug];
}
}
return paramValue;
});
WpfFrontendPage.prototype.getFilterOrderInMainWrapper = (function (paramSlug, mainWrapper, filterWrapper) {
var i = 1,
order = 0;
// get filter order in filter main wrapper
mainWrapper.find('.wpfFilterWrapper').each(function() {
if (jQuery(this).attr('id') == filterWrapper.attr('id')) {
order = i;
}
i++;
});
return order;
});
WpfFrontendPage.prototype.checkNoWooPage = (function () {
var noWooPage = false;
if(jQuery('.wpfMainWrapper').first().attr('data-nowoo')){
noWooPage = true;
}
return noWooPage;
});
WpfFrontendPage.prototype.changeLmpButton = (function () {
var lmpBtn = jQuery('.br_lmp_button_settings .lmp_button');
if (lmpBtn.length) {
var parentStyle = lmpBtn.parent().attr('style').replace(' ', '');
if (parentStyle.indexOf('display:none') > -1) {
return;
}
var url = lmpBtn.attr('href').split('?')[0];
url += window.location.search;
url = url.indexOf('/page/2') > -1 ? url : url.replace(/\/page\/[0-9]{1,}/ig, '/page/2');
lmpBtn.attr('href', url);
setTimeout(function(){
jQuery('.woocommerce-pagination').addClass('wpfHidden');
}, 1000);
}
});
WpfFrontendPage.prototype.changeUrlByFilterParams = (function ($filtersDataFrontend) {
var _thisObj = this.$obj,
noWooPage = _thisObj.noWoo;
if (typeof $filtersDataFrontend !== 'undefined' && $filtersDataFrontend.length > 0) {
// the array is defined and has at least one element
var count = $filtersDataFrontend.length,
filterWrapper = jQuery('.wpfMainWrapper'),
priceFlag = true;
for(var i = 0; i < count; i++){
switch ($filtersDataFrontend[i]['id']){
case 'wpfPrice':
if(priceFlag){
var minPrice = $filtersDataFrontend[i]['settings']['min_price'],
maxPrice = $filtersDataFrontend[i]['settings']['max_price'];
if (typeof minPrice !== 'undefined' && minPrice.length > 0) {
_thisObj.QStringWork('min_price', minPrice, noWooPage, filterWrapper, 'change');
}else{
_thisObj.QStringWork('min_price', '', noWooPage, filterWrapper, 'remove');
}
if (typeof maxPrice !== 'undefined' && maxPrice.length > 0) {
_thisObj.QStringWork('max_price', maxPrice, noWooPage, filterWrapper, 'change');
}else{
_thisObj.QStringWork('max_price', '', noWooPage, filterWrapper, 'remove');
}
priceFlag = false;
}
break;
case 'wpfPriceRange':
if(priceFlag){
var minPrice = $filtersDataFrontend[i]['settings']['min_price'],
maxPrice = $filtersDataFrontend[i]['settings']['max_price'];
if (typeof minPrice !== 'undefined' && minPrice.length > 0 ) {
_thisObj.QStringWork('min_price', minPrice, noWooPage, filterWrapper, 'change');
}else{
_thisObj.QStringWork('min_price', '', noWooPage, filterWrapper, 'remove');
}
if (typeof maxPrice !== 'undefined' && maxPrice.length > 0) {
_thisObj.QStringWork('max_price', maxPrice, noWooPage, filterWrapper, 'change');
}else{
_thisObj.QStringWork('max_price', '', noWooPage, filterWrapper, 'remove');
}
priceFlag = false;
}
break;
case 'wpfSortBy':
var orderby = $filtersDataFrontend[i]['settings']['orderby'];
if (typeof orderby !== 'undefined' && orderby.length > 0 ) {
_thisObj.QStringWork('orderby', orderby, noWooPage, filterWrapper, 'change');
}else{
_thisObj.QStringWork('orderby', '', noWooPage, filterWrapper, 'remove');
}
break;
case 'wpfCategory':
case 'wpfPerfectBrand':
var product_cat = $filtersDataFrontend[i]['settings']['settings'],
name = $filtersDataFrontend[i]['name'],
delim = $filtersDataFrontend[i]['delim'];
product_cat = product_cat.join(delim ? delim : '|');
if (typeof product_cat !== 'undefined' && product_cat.length > 0) {
_thisObj.QStringWork(name, product_cat, noWooPage, filterWrapper, 'change');
}else{
_thisObj.QStringWork(name, '', noWooPage, filterWrapper, 'remove');
}
break;
case 'wpfTags':
var product_tag = $filtersDataFrontend[i]['settings']['settings'],
name = $filtersDataFrontend[i]['name'],
delim = $filtersDataFrontend[i]['delim'];
product_tag = product_tag.join(delim ? delim : '|');
if (typeof product_tag !== 'undefined' && product_tag.length > 0) {
_thisObj.QStringWork(name, product_tag, noWooPage, filterWrapper, 'change');
}else{
_thisObj.QStringWork(name, '', noWooPage, filterWrapper, 'remove');
}
break;
case 'wpfAttribute':
var product_taxonomy = $filtersDataFrontend[i]['settings']['taxonomy'],
product_attr = $filtersDataFrontend[i]['settings']['settings'],
delim = $filtersDataFrontend[i]['delim'];
product_attr = product_attr.join(delim ? delim : '|');
if (typeof product_attr !== 'undefined' && product_attr.length > 0) {
_thisObj.QStringWork(product_taxonomy, product_attr, noWooPage, filterWrapper, 'change');
}else{
_thisObj.QStringWork(product_taxonomy, '', noWooPage, filterWrapper, 'remove');
}
break;
case 'wpfAuthor':
var authorVal = $filtersDataFrontend[i]['settings']['settings'],
name = $filtersDataFrontend[i]['name'],
delim = $filtersDataFrontend[i]['delim'];
authorVal = authorVal.join(delim ? delim : '|');
if (typeof authorVal !== 'undefined' && authorVal.length > 0) {
_thisObj.QStringWork('pr_author', authorVal, noWooPage, filterWrapper, 'change');
}else{
_thisObj.QStringWork('pr_author', '', noWooPage, filterWrapper, 'remove');
}
break;
case 'wpfFeatured':
var featureVal = $filtersDataFrontend[i]['settings']['settings'];
if (typeof featureVal !== 'undefined' && featureVal.length > 0) {
_thisObj.QStringWork('pr_featured', featureVal, noWooPage, filterWrapper, 'change');
}else{
_thisObj.QStringWork('pr_featured', '', noWooPage, filterWrapper, 'remove');
}
break;
case 'wpfOnSale':
var onSaleVal = $filtersDataFrontend[i]['settings']['settings'];
if (typeof onSaleVal !== 'undefined' && onSaleVal.length > 0) {
_thisObj.QStringWork('pr_onsale', onSaleVal, noWooPage, filterWrapper, 'change');
}else{
_thisObj.QStringWork('pr_onsale', '', noWooPage, filterWrapper, 'remove');
}
break;
case 'wpfInStock':
var pr_stock = $filtersDataFrontend[i]['settings']['settings'];
pr_stock = pr_stock.join(delim ? delim : '|');
if (typeof pr_stock !== 'undefined' && pr_stock.length > 0 ) {
_thisObj.QStringWork('pr_stock', pr_stock, noWooPage, filterWrapper, 'change');
}else{
_thisObj.QStringWork('pr_stock', '', noWooPage, filterWrapper, 'remove');
}
break;
case 'wpfRating':
var ratingVal = $filtersDataFrontend[i]['settings']['settings'];
if (typeof ratingVal !== 'undefined' && checkArray(ratingVal) && ratingVal.length > 0 ) {
_thisObj.QStringWork('pr_rating', ratingVal, noWooPage, filterWrapper, 'change');
}else{
_thisObj.QStringWork('pr_rating', '', noWooPage, filterWrapper, 'remove');
}
break;
default:
if(typeof(_thisObj.changeUrlByFilterParamsPro) == 'function') {
_thisObj.changeUrlByFilterParamsPro($filtersDataFrontend[i], noWooPage, filterWrapper);
}
break;
}
}
}else{
return false;
}
});
WpfFrontendPage.prototype.changeSlugByUrl = (function () {
jQuery('.wpfSlugWrapper .wpfSlug').remove();
var _thisObj = this.$obj,
noWooPage = _thisObj.noWoo;
if(noWooPage){
if( jQuery('.wpfMainWrapper').first().attr('data-hide-url')){
var searchParams = jQuery.toQueryParams(jQuery('.wpfMainWrapper').first().attr('data-hide-url'));
}
}else{
var searchParams = jQuery.toQueryParams(window.location.search);
}
for (var key in searchParams) {
if(key === 'min_price' || key === 'max_price'){
key = 'min_price,max_price';
}
if(jQuery('.wpfFilterWrapper[data-get-attribute="'+key+'"]').length > 0){
var elem = jQuery('.wpfFilterWrapper[data-get-attribute="'+key+'"]').first(),
$slug = elem.attr('data-slug'),
$label = elem.attr('data-label'),
$title = elem.attr('data-title'),
$getAttr = elem.attr('data-get-attribute'),
$filterType = elem.attr('data-filter-type');
if(typeof $title != 'undefined') $label = $title;
else if(typeof $label == 'undefined') $label = $slug;
var html = '';
if(jQuery('.wpfSlugWrapper').length > 0){
if( !jQuery('.wpfSlugWrapper .wpfSlug[data-slug="'+$slug+'"]').length > 0 ) {
html += '';
jQuery('.wpfSlugWrapper').append(html);
}
}else{
if( !jQuery('.wpfSlugWrapper .wpfSlug[data-slug="'+$slug+'"]').length > 0 ) {
html += '';
jQuery('.storefront-sorting').append(html);
}
}
}
}
});
WpfFrontendPage.prototype.sendFiltersOptionsByAjax = (function ($filtersDataBackend, $queryVars, $filterSettings, $generalSettings, $woocommerceSettings, $shortcodeAttr) {
var _thisObj = this.$obj,
$wrapperSettings = [];
if ( window.wpfAdminPage ) {
return false;
}
_thisObj.enableFiltersLoader();
if ($filterSettings === undefined) {
$filterSettings = [];
} else {
$filterSettings = JSON.stringify($filterSettings);
}
if (typeof $generalSettings === 'undefined') {
$generalSettings = [];
} else {
$wrapperSettings = $generalSettings['settings'];
$generalSettings = $generalSettings['settings']['filters']['order']
}
/**
* There are some cases when we do not provide ajax functionlity
*/
if ( window.InfiniteScroll && window.InfiniteScroll.prototype ) {
/**
* Flatsome theme compability
* We do not privide ajax functionlity with infinite scroll
*
* @link https://themeforest.net/item/flatsome-multipurpose-responsive-woocommerce-theme/5484319
*/
if (jQuery('body').hasClass('theme-flatsome')) {
location.reload();
return;
}
}
jQuery.sendFormWpf({
data: {
mod: 'woofilters',
action: 'filtersFrontend',
filtersDataBackend: JSON.stringify($filtersDataBackend),
queryvars: $queryVars,
filterSettings: $filterSettings,
generalSettings: $generalSettings,
shortcodeAttr: $shortcodeAttr,
woocommerceSettings: JSON.stringify($woocommerceSettings),
currenturl: window.location.href,
},
onSuccess: function(res) {
if(!res.error) {
var catSelector = wpfGetSelector(res.data['categoryHtml'], true, 'ul.products'),
loopSelector = wpfGetSelector(res.data['loopStartHtml'], true, 'ul.products', 3);
if (typeof jQuery('.product-categories-wrapper') !== 'undefined' && jQuery('.product-categories-wrapper > ul.products').length > 0) {
//replace cats html
if (res.data['categoryHtml'].length) {
jQuery('.product-categories-wrapper > ul.products').html(res.data['categoryHtml']);
}
//replace products html
jQuery('ul.products').eq(1).html(res.data['productHtml']);
} else if (jQuery('.elementor-widget-container ul.products').length > 0) {
jQuery('.elementor-widget-container ul.products').each(function(){
if (!jQuery(this).find('.product-category').length) {
jQuery(this).html(res.data['categoryHtml']+res.data['productHtml']);
}
});
} else if (jQuery('.woocommerce > .products[data-filterargs][data-innerargs]').length > 0) {
jQuery('.woocommerce > .products[data-filterargs][data-innerargs]').html(res.data['categoryHtml']+res.data['productHtml']);
} else {
var loopContainer = jQuery(loopSelector);
if(!loopContainer.length
&& !jQuery('.wpfMainWrapper').attr('data-nowoo') !== typeof undefined
&& !jQuery('.wpfMainWrapper').attr('data-nowoo') !== false) {
location.reload();
}
loopContainer.each(function(){
//replace cats html
jQuery(this).html(res.data['categoryHtml']);
//replace products html
jQuery(this).append(res.data['productHtml']);
});
}
var countSelector = wpfGetSelector(res.data['resultCountHtml'], true, '.woocommerce-result-count'),
wooCount = jQuery(countSelector);
if(wooCount.length > 0) {
wooCount.replaceWith(res.data['resultCountHtml']);
}
var isLeerPagination = res.data['paginationHtml'] == '',
paginationSelector = wpfGetSelector(res.data[isLeerPagination ? 'paginationLeerHtml' : 'paginationHtml'], false, '.woocommerce-pagination'),
wooPagination = jQuery(paginationSelector),
newPagination = res.data['paginationHtml'];
if(wooPagination.length > 0) {
if(typeof _thisObj.paginationClasses == 'undefined') {
_thisObj.paginationClasses = wooPagination.attr('class');
}
if(isLeerPagination) {
wooPagination.css({'display':'none'});
} else {
wooPagination.replaceWith(newPagination);
}
} else if(!isLeerPagination) {
var afterLoop = jQuery('.after-shop-loop');
if(afterLoop.length > 0) {
afterLoop.prepend(newPagination);
} else {
wooCount = jQuery('.storefront-sorting ' + countSelector);
if(wooCount.length > 0) {
wooCount.after(newPagination);
} else {
jQuery(loopSelector).eq(0).after(newPagination);
}
}
}
if(typeof _thisObj.paginationClasses != 'undefined') {
jQuery(paginationSelector).attr('class', _thisObj.paginationClasses);
}
//if changed min/max price and we have wpfPrice filter
//we need change slider
_thisObj.getUrlParamsChangeFiltersValues();
_thisObj.disableFiltersLoader();
_thisObj.removeOverlay();
toggleClear();
/*if ( jQuery('body').find('.products').hasClass('oceanwp-row') ) {
jQuery('body').find('.products li:first').addClass('entry').addClass('has-media').addClass('col').addClass('span_1_of_4').addClass('owp-content-left');
}*/
_thisObj.changeLmpButton();
// for yith quick view
jQuery(document).trigger('yith_wcqv_wcajaxnav_update');
if (typeof(_thisObj.scrollToProductsPro) == 'function') {
_thisObj.scrollToProductsPro($wrapperSettings);
}
if (jQuery('ul.products').closest('.et_pb_shop').length) {
heightIdenticalInRow('.et_pb_shop li.product');
}
// event for custom javascript hook, example: document.addEventListener('wpfAjaxSuccess', function(event) {alert('Custom js');});
//document.dispatchEvent(new Event('wpfAjaxSuccess')); - not work in IE11
var customEvent = document.createEvent('Event');
customEvent.initEvent('wpfAjaxSuccess', false, true);
document.dispatchEvent(customEvent);
}
}
});
});
WpfFrontendPage.prototype.enableFiltersLoader =(function(){
var preview = jQuery('.wpfPreviewLoader').first().clone().removeClass('wpfHidden');
jQuery('ul.products').html(preview);
});
WpfFrontendPage.prototype.disableFiltersLoader =(function(){
jQuery('.wpfPreviewLoader').first().clone().addClass('wpfHidden');
});
//after load change price and price range filters params if find get params
WpfFrontendPage.prototype.getUrlParamsChangeFiltersValues = (function(){
var _thisObj = this.$obj,
noWooPage = _thisObj.noWoo;
if(noWooPage){
var curUrl = jQuery('.wpfMainWrapper').first().attr('data-hide-url');
}else{
var curUrl = window.location.href;
}
if(!curUrl){
return;
}
//get all get params
var urlParams = _thisObj.findGetParameter(curUrl);
jQuery('.wpfFilterWrapper').each(function () {
var $filter = jQuery(this),
filterType = $filter.attr('data-filter-type'),
settings = _thisObj.getFilterMainSettings($filter.closest('.wpfMainWrapper'));
switch(filterType){
case 'wpfAttribute':
if(typeof(_thisObj.eventChangeFilterPro) == 'function') {
_thisObj.eventChangeFilterPro($filter, settings);
}
break;
case 'wpfPrice':
var minPrice = urlParams.min_price ? urlParams.min_price : $filter.attr('data-minvalue'),
maxPrice = urlParams.max_price ? urlParams.max_price : $filter.attr('data-maxvalue'),
skin = 'default';
if(minPrice){
$filter.find('#wpfMinPrice').val(minPrice);
}
if(maxPrice){
$filter.find('#wpfMaxPrice').val(maxPrice);
}
if(settings){
skin = $filter.attr('data-price-skin');
}
if(skin === 'default'){
var sliderWrapper = $filter.find("#wpfSliderRange");
}else{
var sliderWrapper = $filter.find('.ion-range-slider').data('ionRangeSlider');
$filter.addClass('wpfNotActiveSlider');
}
if(minPrice && maxPrice){
if(skin === 'default'){
sliderWrapper.slider({
values: [minPrice, maxPrice]
});
}else if(typeof(sliderWrapper) != 'undefined') {
sliderWrapper.update({from: minPrice, to: maxPrice});
$filter.removeClass('wpfNotActiveSlider');
}
}
_thisObj.chageRangeFieldWidth();
if(typeof(_thisObj.eventChangeFilterPro) == 'function') {
_thisObj.eventChangeFilterPro($filter, settings);
}
break;
case 'wpfPriceRange':
var minPrice = urlParams.min_price ? parseFloat(urlParams.min_price) : false,
maxPrice = urlParams.max_price ? parseFloat(urlParams.max_price) : false,
$options = $filter.find('li');
$options.find('input[type="checkbox"]').prop('checked', false);
$options.each(function () {
var _this = jQuery(this),
range = _this.attr('data-range');
if(typeof range != 'undefined') {
range = range.split(',');
var minRange = range[0] == '' ? false : parseFloat(range[0]),
maxRange = range[1] == '' ? false : parseFloat(range[1]);
if(minPrice === minRange && maxPrice === maxRange ){
_this.find('input[type="checkbox"]').prop('checked', true);
return false;
}
}
});
if(typeof(_thisObj.eventChangeFilterPro) == 'function') {
_thisObj.eventChangeFilterPro($filter, settings);
}
break;
}
});
});
WpfFrontendPage.prototype.findGetParameter =(function(url){
// This function is anonymous, is executed immediately and
// the return value is assigned to QueryString!
var query_string = {},
usefulParam = url.split("?")[1] || "",
query = usefulParam || "",
vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
// If first entry with this name
if (typeof query_string[pair[0]] === "undefined") {
query_string[pair[0]] = decodeURIComponent(pair[1]);
// If second entry with this name
} else if (typeof query_string[pair[0]] === "string") {
var arr = [query_string[pair[0]], decodeURIComponent(pair[1])];
query_string[pair[0]] = arr;
// If third or later entry with this name
} else {
query_string[pair[0]].push(decodeURIComponent(pair[1]));
}
}
return query_string;
});
WpfFrontendPage.prototype.getClearLabel = (function (label, withCount) {
if(withCount) {
var cnt = label.lastIndexOf('(');
if(cnt == -1) cnt = label.lastIndexOf(' 0) {
var getParams = $filter.attr('data-get-attribute');
getParams = getParams.split(",");
if (typeof options[0] !== 'undefined' && options[0].length > 0) {
var prices = options[0].split(',');
frontendOptions[getParams[0]] = prices[0];
frontendOptions[getParams[1]] = prices[1];
}
}
if(options.length == 0) {
var defRange = $filter.attr('data-default');
if(typeof defRange != 'undefined' && defRange.length) {
options[i] = defRange;
}
}
optionsArray['backend'] = options;
optionsArray['frontend'] = frontendOptions;
optionsArray['selected'] = selectedOptions;
return optionsArray;
});
WpfFrontendPage.prototype.getSortByFilterOptions = (function ($filter) {
var optionsArray = [],
option = $filter.find('option:selected'),
value = option.val();
//options for backend (filtering)
optionsArray['backend'] = value;
//options for frontend(change url)
var frontendOptions = [],
selectedOptions = {'is_one': true, 'list': []},
getParams = $filter.attr('data-get-attribute');
if(value.length) {
selectedOptions['list'][0] = option.html();
}
frontendOptions[getParams] = value;
optionsArray['frontend'] = frontendOptions;
optionsArray['selected'] = selectedOptions;
return optionsArray;
});
WpfFrontendPage.prototype.getInStockFilterOptions = (function ($filter) {
var optionsArray = [],
frontendOptions = [],
options = [],
filterType = $filter.attr('data-display-type'),
selectedOptions = {'is_one': (filterType === 'dropdown'), 'list': []},
i = 0;
//options for backend (filtering)
if(filterType === 'dropdown'){
var option = $filter.find(":selected"),
value = option.attr('data-slug');
if(value != '') {
options[i] = value;
frontendOptions[i] = value;
selectedOptions['list'][i] = option.html();
}
} else {
$filter.find('input:checked').each(function () {
var li = jQuery(this).closest('li'),
slug = li.attr('data-term-slug');
options[i] = slug;
frontendOptions[i] = slug;
selectedOptions['list'][li.attr('data-term-id')] = li.find('.wpfValue').html();
i++;
});
}
optionsArray['backend'] = options;
//options for frontend(change url)
var getParams = $filter.attr('data-get-attribute');
optionsArray['frontend'] = [];
optionsArray['frontend']['taxonomy'] = getParams;
optionsArray['frontend']['settings'] = frontendOptions;
optionsArray['selected'] = selectedOptions;
return optionsArray;
});
WpfFrontendPage.prototype.getCategoryFilterOptions = (function ($filter) {
var _thisObj = this.$obj,
optionsArray = [],
frontendOptions = [],
options = [],
filterType = $filter.attr('data-display-type'),
selectedOptions = {'is_one': (filterType == 'list' || filterType == 'dropdown'), 'list': []},
i = 0;
//options for backend (filtering)
if(filterType === 'dropdown'){
var option = $filter.find(":selected"),
id = option.attr('data-term-id'),
value = option.val();
if(value != '') {
options[i] = value;
selectedOptions['list'][id] = _thisObj.getClearLabel(option.html(), $filter.hasClass('wpfShowCount'));
}
frontendOptions[i] = id;
} else if(filterType === 'mul_dropdown'){
$filter.find(':selected').each(function () {
var option = jQuery(this);
options[i] = option.val();
frontendOptions[i] = option.attr('data-term-id');
selectedOptions['list'][option.attr('data-term-id')] = _thisObj.getClearLabel(option.html(), $filter.hasClass('wpfShowCount'));
i++;
});
} else {
var removeSelectedList = [];
$filter.find('input').each(function () {
var inputCurent = jQuery(this),
liCurent = inputCurent.closest('li'),
id = liCurent.data('term-id'),
isParent = liCurent.children('ul').length > 0,
isChecked = inputCurent.is(':checked'),
hierarchicalLogic = $filter.attr('data-logic-hierarchical'),
type = $filter.attr('data-display-type'),
isHierarchical = $filter.attr('data-show-hierarchical'),
isHierarchicalLogic = isHierarchical === 'true' && type === 'multi' || type === 'text';
if ( isParent ) {
var isAllChildChecked = true,
childList = [];
liCurent.find('ul li').each(function() {
var childId = jQuery(this).data('term-id'),
childLi = jQuery(this),
childInput = childLi.find('input'),
isChildChecked = childInput.prop('checked');
childList.push(childId);
if (!isChildChecked) {
isAllChildChecked = false;
return false;
}
});
if (isChecked && isAllChildChecked) {
removeSelectedList = removeSelectedList.concat(childList);
var onlyUnique = function(value, index, self) {
return self.indexOf(value) === index;
}
removeSelectedList = removeSelectedList.filter( onlyUnique );
selectedOptions.removeSelected = removeSelectedList;
}
}
if (jQuery(this).is(':checked')) {
if ( isHierarchicalLogic && hierarchicalLogic == 'child' ) {
var liElements = liCurent.find('li'),
isChildChicked = false;
for (var j = 0; j < liElements.length; ++j) {
var li = liElements[j];
if (jQuery(li).find('input').prop('checked')) {
isChildChicked = true;
}
}
if (!isChildChicked) {
options[i] = id;
frontendOptions[i] = id;
}
} else if(isHierarchicalLogic && hierarchicalLogic == 'parent') {
var parents = liCurent.parents('li'),
isChildChicked = false;
for (var j = 0; j < parents.length; ++j) {
var li = parents[j];
if (jQuery(li).find('input').prop('checked')) {
isChildChicked = true;
}
}
if (!isChildChicked) {
options[i] = id;
frontendOptions[i] = id;
}
} else {
options[i] = id;
frontendOptions[i] = id;
}
selectedOptions['list'][id] = liCurent.find('.wpfValue').html();
i++;
}
});
}
var options = options.filter(function (el) {
return el != null;
});
var frontendOptions = frontendOptions.filter(function (el) {
return el != null;
});
optionsArray['backend'] = options;
//options for frontend(change url)
var getParams = $filter.attr('data-get-attribute');
optionsArray['frontend'] = [];
optionsArray['frontend']['taxonomy'] = getParams;
optionsArray['frontend']['settings'] = frontendOptions;
optionsArray['selected'] = selectedOptions;
return optionsArray;
});
WpfFrontendPage.prototype.getPerfectBrandFilterOptions = (function ($filter) {
return this.$obj.getCategoryFilterOptions($filter);
});
WpfFrontendPage.prototype.getTagsFilterOptions = (function ($filter) {
var _thisObj = this.$obj,
optionsArray = [],
options = [],
frontendOptions = [],
filterType = $filter.attr('data-display-type'),
selectedOptions = {'is_one': (filterType == 'dropdown'), 'list': []},
withCount = $filter.hasClass('wpfShowCount'),
i = 0;
//options for backend (filtering)
if(filterType === 'dropdown'){
var option = $filter.find(":selected"),
value = option.val();
if(value != '') {
options[i] = value;
frontendOptions[i] = option.attr('data-slug');
selectedOptions['list'][option.attr('data-term-id')] = _thisObj.getClearLabel(option.html(), withCount);
}
} else if (filterType === 'mul_dropdown'){
$filter.find(':selected').each(function () {
var option = jQuery(this);
options[i] = option.val();
frontendOptions[i] = option.attr('data-slug');
selectedOptions['list'][option.attr('data-term-id')] = _thisObj.getClearLabel(option.html(), withCount);
i++;
});
} else {
$filter.find('input:checked').each(function () {
var li = jQuery(this).closest('li'),
id = li.attr('data-term-id');
options[i] = id;
frontendOptions[i] = li.attr('data-term-slug');
selectedOptions['list'][id] = li.find('.wpfValue').html();
i++;
});
}
optionsArray['backend'] = options;
//options for frontend(change url)
var getParams = $filter.attr('data-get-attribute');
optionsArray['frontend'] = [];
optionsArray['frontend']['taxonomy'] = getParams;
optionsArray['frontend']['settings'] = frontendOptions;
optionsArray['selected'] = selectedOptions;
return optionsArray;
});
WpfFrontendPage.prototype.getAttributeFilterOptions = (function ($filter) {
var _thisObj = this.$obj,
optionsArray = [],
options = [],
frontendOptions = [],
filterType = $filter.attr('data-display-type'),
selectedOptions = {'is_one': (filterType == 'dropdown'), 'list': []},
withCount = $filter.hasClass('wpfShowCount'),
i = 0,
proFilterType = [
'slider',
'colors'
];
//options for backend (filtering)
if (filterType === 'dropdown'){
var option = $filter.find(":selected"),
value = option.val();
if (value != '') {
options[i] = value;
frontendOptions[i] = option.attr('data-slug');
selectedOptions['list'][option.attr('data-term-id')] = _thisObj.getClearLabel(option.html(), withCount);
}
} else if (filterType === 'mul_dropdown'){
$filter.find(':selected').each(function () {
var option = jQuery(this);
options[i] = option.val();
frontendOptions[i] = option.attr('data-slug');
selectedOptions['list'][option.attr('data-term-id')] = _thisObj.getClearLabel(option.html(), withCount);
i++;
});
} else if (jQuery.inArray(filterType, proFilterType) == -1 ) {
$filter.find('input:checked').each(function () {
var li = jQuery(this).closest('li'),
id = li.attr('data-term-id');
options[i] = id;
frontendOptions[i] = li.attr('data-term-slug');
selectedOptions['list'][id] = li.find('.wpfValue').html();
i++;
});
}
var data = {
options : options,
frontendOptions : frontendOptions,
selectedOptions : selectedOptions,
i : i,
}
if (typeof window.wpfFrontendPage.getAttributeFilterOptionsPro == 'function') {
data = window.wpfFrontendPage.getAttributeFilterOptionsPro($filter, data);
}
optionsArray['backend'] = data.options;
//options for frontend(change url)
var getParams = $filter.attr('data-get-attribute');
optionsArray['frontend'] = [];
optionsArray['frontend']['taxonomy'] = getParams;
optionsArray['frontend']['settings'] = data.frontendOptions;
optionsArray['selected'] = data.selectedOptions;
return optionsArray;
});
WpfFrontendPage.prototype.getAuthorFilterOptions = (function ($filter) {
var _thisObj = this.$obj,
optionsArray = [],
options = [],
frontendOptions = [],
filterType = $filter.attr('data-display-type'),
selectedOptions = {'is_one': (filterType == 'dropdown'), 'list': []},
i = 0;
//options for backend (filtering)
if(filterType === 'list'){
$filter.find('input:checked').each(function () {
var li = jQuery(this).closest('li'),
id = li.attr('data-term-id');
options[i] = id;
frontendOptions[i] = li.attr('data-term-slug');
selectedOptions['list'][id] = li.find('.wpfValue').html();
i++;
});
} else if (filterType === 'mul_dropdown'){
$filter.find(':selected').each(function () {
var option = jQuery(this);
options[i] = option.val();
frontendOptions[i] = option.attr('data-slug');
selectedOptions['list'][option.attr('data-term-id')] = _thisObj.getClearLabel(option.html());
i++;
});
} else if (filterType === 'dropdown'){
var option = $filter.find(":selected"),
value = option.val();
options[i] = value;
if(value != '') {
frontendOptions[i] = option.attr('data-slug');
selectedOptions['list'][option.attr('data-term-id')] = option.html();
}
}
optionsArray['backend'] = options;
//options for frontend(change url)
var getParams = $filter.attr('data-get-attribute');
optionsArray['frontend'] = [];
optionsArray['frontend']['taxonomy'] = getParams;
optionsArray['frontend']['settings'] = frontendOptions;
optionsArray['selected'] = selectedOptions;
return optionsArray;
});
WpfFrontendPage.prototype.getFeaturedFilterOptions = (function ($filter) {
var optionsArray = [],
options = [],
frontendOptions = [],
filterType = $filter.attr('data-display-type'),
selectedOptions = {'is_one': (filterType == 'dropdown'), 'list': []},
i = 0;
$filter.find('input:checked').each(function () {
var li = jQuery(this).closest('li'),
id = li.attr('data-term-id');
options[i] = id;
frontendOptions[i] = li.attr('data-term-slug');
selectedOptions['list'][id] = li.find('.wpfValue').html();
i++;
});
optionsArray['backend'] = options;
//options for frontend(change url)
var getParams = $filter.attr('data-get-attribute');
optionsArray['frontend'] = [];
optionsArray['frontend']['taxonomy'] = getParams;
optionsArray['frontend']['settings'] = frontendOptions;
optionsArray['selected'] = selectedOptions;
return optionsArray;
});
WpfFrontendPage.prototype.getOnSaleFilterOptions = (function ($filter) {
var optionsArray = [],
options = [],
frontendOptions = [],
filterType = $filter.attr('data-display-type'),
selectedOptions = {'is_one': (filterType == 'dropdown'), 'list': []},
i = 0;
$filter.find('input:checked').each(function () {
var li = jQuery(this).closest('li'),
id = li.attr('data-term-id');
options[i] = id;
frontendOptions[i] = li.attr('data-term-slug');
selectedOptions['list'][id] = li.find('.wpfValue').html();
i++;
});
optionsArray['backend'] = options;
//options for frontend(change url)
var getParams = $filter.attr('data-get-attribute');
optionsArray['frontend'] = [];
optionsArray['frontend']['taxonomy'] = getParams;
optionsArray['frontend']['settings'] = frontendOptions;
optionsArray['selected'] = selectedOptions;
return optionsArray;
});
WpfFrontendPage.prototype.getRatingFilterOptions = (function ($filter) {
var optionsArray = [],
frontendOptions = [],
options = [],
filterType = $filter.attr('data-display-type'),
selectedOptions = {'is_one': true, 'list': []},
i = 0;
//options for backend (filtering)
if(filterType == 'linestars' || filterType == 'liststars'){
var input = $filter.find('input.wpfStarInput:checked'),
rating = input.val();
options[i] = rating;
frontendOptions[i] = rating;
selectedOptions['list'][i] = input.attr('data-label');
}else if(filterType == 'list'){
$filter.find('input:checked').each(function () {
var li = jQuery(this).closest('li'),
id = li.attr('data-term-id');
options[i] = id;
frontendOptions[i] = li.attr('data-term-slug');
selectedOptions['list'][id] = li.find('.wpfValue').html();
i++;
});
}else if(filterType == 'dropdown'){
var option = $filter.find(":selected"),
value = option.val();
options[i] = value;
if(value != '') {
frontendOptions[i] = option.attr('data-slug');
selectedOptions['list'][option.attr('data-term-id')] = option.html();
}
}
optionsArray['backend'] = options;
//options for frontend(change url)
var getParams = $filter.attr('data-get-attribute');
optionsArray['frontend'] = [];
optionsArray['frontend']['taxonomy'] = getParams;
optionsArray['frontend']['settings'] = frontendOptions;
optionsArray['selected'] = selectedOptions;
return optionsArray;
});
WpfFrontendPage.prototype.disableLeerOptions = (function () {
var _thisObj = this.$obj;
jQuery('.wpfMainWrapper').each(function () {
var mainWrapper = jQuery(this),
settings = _thisObj.getFilterMainSettings(mainWrapper);
if(settings && settings.settings.filter_null_disabled === '1') {
var filters = mainWrapper.find('.wpfFilterWrapper.wpfShowCount');
if(filters.length) {
filters.find('option[data-term-id]').prop('disabled', false);
filters.find('option[data-term-id][data-count="0"]').prop('disabled', true);
filters.find('.wpfCount').each(function(){
var cntObj = jQuery(this),
leer = cntObj.html() == '(0)',
el = cntObj.closest('[data-term-id]'),
input = false;
if(el.length == 0) {
el = cntObj.closest('[data-term-slug]');
}
if(el.length) {
if(el.is('input')) {
input = el;
el = input.parent();
} else {
input = el.find('input');
}
input.prop('disabled', leer);
if(leer) el.addClass('wpfOptionDisabled');
else el.removeClass('wpfOptionDisabled');
}
});
}
}
});
});
WpfFrontendPage.prototype.addSpecificPluginActions = (function() {
// elementor plugin, action when widgets in admin panek are ready
jQuery(window).on('load', function() {
if ( window.elementorFrontend ) {
if ( window.elementorFrontend.hooks ) {
elementorFrontend.hooks.addAction( 'frontend/element_ready/widget', function( $scope ) {
var wrapper = $scope.find('.wpfMainWrapper');
hideFilterLoader(wrapper);
});
}
} else if ( jQuery('.elementor .wpfMainWrapper').length ) {
setTimeout(function() {
jQuery('.elementor .wpfMainWrapper').each(function() {
var wrapper = jQuery(this);
hideFilterLoader(wrapper);
});
}, 2000);
}
});
});
jQuery(document).ready(function () {
window.wpfFrontendPage = new WpfFrontendPage();
window.wpfFrontendPage.init();
});
}(window.jQuery));
var objQueryString={};
toggleClear();
function wpfGetSelector(html, controlExist, defSelector, countChilds) {
if(html.length == 0) return defSelector;
var elem = jQuery(html),
selector = '',
i = 0;
if(typeof countChilds == 'undefined') countChilds = 1;
while(i < countChilds && elem && elem.length) {
if(i > 0) selector += ' ';
i++;
if(elem.length > 1) elem = elem.last();
var elemId = elem.attr('id');
if(typeof elemId != 'undefined') {
selector += '#' + elemId;
} else {
var elemClass = elem.attr('class');
if(typeof elemClass != 'undefined') {
if(elemClass == 'container' && countChilds == 1) countChilds = 2;
selector += elem.get(0).tagName + '.' + elemClass.trim().replace(/ +/g, '.');
}
}
if(controlExist && selector != '' && jQuery(selector).length == 0) {
selector = '';
break;
}
var elem = elem.children();
}
return selector.length == 0 ? defSelector : selector;
}
function getUrlParams () {
var params={};
window.location.search
.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(str,key,value) {
params[key] = value;
}
);
return params;
}
function toggleClear() {
var params = getUrlParams();
jQuery(".wpfBlockClear").hide();
jQuery(".wpfFilterWrapper").each(function(){
var attr = jQuery(this).attr('data-get-attribute');
if (attr in params) {
jQuery(this).find(".wpfBlockClear").show();
}
});
if ('min_price' in params || 'max_price' in params) {
jQuery("[data-filter-type='wpfPrice']").find(".wpfBlockClear").show();
jQuery("[data-filter-type='wpfPriceRange']").find(".wpfBlockClear").show();
}
}
//Get querystring value
function getParameterByName(name, searchUrl) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^]*)"),
results = regex.exec(searchUrl);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
//Add or modify querystring
function changeUrl(filterSlug, filterValue, $wooPage, $filterWrapper) {
removePageQString();
//Get query string filterValue
$wooPage = (typeof $wooPage != 'undefined' ? $wooPage: false);
if(!$wooPage){
var searchUrl = decodeURIComponent(location.search);
}else{
if($filterWrapper.attr('data-hide-url')){
var searchUrl=$filterWrapper.attr('data-hide-url');
} else {
var searchUrl = '';
}
}
if(searchUrl.indexOf("?")== "-1") {
var urlValue='?'+filterSlug+'='+filterValue;
if(!$wooPage){
history.pushState({state:1, rand: Math.random()}, '', encodeURI(urlValue).indexOf('%25') === -1 ? encodeURI(urlValue) : urlValue);
}
} else {
//Check for filterSlug in query string, if not present
if(searchUrl.indexOf('&'+filterSlug+'=')== "-1" && searchUrl.indexOf('?'+filterSlug+'=')== "-1") {
var urlValue=searchUrl+'&'+filterSlug+'='+filterValue;
//If filterSlug present in query string
} else {
var oldValue = getParameterByName(filterSlug, searchUrl);
if(searchUrl.indexOf("?"+filterSlug+"=")!= "-1") {
var urlValue = searchUrl.replace('?'+filterSlug+'='+oldValue,'?'+filterSlug+'='+filterValue);
// add existing in url filter with another option
} else {
var urlValue = searchUrl.replace('&'+filterSlug+'='+oldValue,'&'+filterSlug+'='+filterValue);
}
}
if(!$wooPage){
history.pushState({state:1, rand: Math.random()}, '', encodeURI(urlValue).indexOf('%25') === -1 ? encodeURI(urlValue) : urlValue);
}
//history.pushState function is used to add history state.
//It takes three parameters: a state object, a title (which is currently ignored), and (optionally) a URL.
}
objQueryString.key=filterValue;
return urlValue;
}
function removePageQString() {
var path = document.location.pathname,
page = path.indexOf('/page/');
if(page != -1 && history.pushState) {
history.pushState({state:1, rand: Math.random()}, '', path.substr(0, page + 1) + location.search);
}
}
//Function used to remove querystring
function removeQString(key, $wooPage, $filterWrapper) {
removePageQString();
//Get query string value
var urlValue=decodeURI(document.location.href);
$wooPage = (typeof $wooPage != 'undefined' ? $wooPage: false);
if(!$wooPage){
var searchUrl=decodeURIComponent(location.search);
}else{
if($filterWrapper.attr('data-hide-url')){
var searchUrl=decodeURI($filterWrapper.attr('data-hide-url'));
}else {
var searchUrl = '';
}
var urlValue=document.location.href + searchUrl;
}
if(key!="") {
var oldValue = getParameterByName(key, searchUrl),
removeVal=key+"="+oldValue;
if(searchUrl.indexOf('?'+removeVal+'&')!= "-1") {
urlValue=urlValue.replace('?'+removeVal+'&','?');
}
else if(searchUrl.indexOf('&'+removeVal+'&')!= "-1") {
urlValue=urlValue.replace('&'+removeVal+'&','&');
}
else if(searchUrl.indexOf('?'+removeVal)!= "-1") {
urlValue=urlValue.replace('?'+removeVal,'');
}
else if(searchUrl.indexOf('&'+removeVal)!= "-1") {
urlValue=urlValue.replace('&'+removeVal,'');
}
if($wooPage){
urlValue = urlValue.replace(document.location.href,'');
}
} else {
if(!$wooPage){
var searchUrl=decodeURIComponent(location.search);
urlValue=urlValue.replace(searchUrl,'');
}else{
var searchUrl=$filterWrapper.attr('data-hide-url');
urlValue=urlValue.replace(searchUrl,'');
urlValue = urlValue.replace(document.location.href,'');
}
}
if(!$wooPage){
history.pushState({state:1, rand: Math.random()}, '', encodeURI(urlValue).indexOf('%25') === -1 ? encodeURI(urlValue) : urlValue);
}
return urlValue.indexOf('%25') !== -1 ? decodeURI(urlValue) : urlValue;
}
function checkArray(my_arr){
for(var i=0;i 0) {
var taxonomy = filter.data('taxonomy');
if(typeof taxonomy == 'undefined' || taxonomy.length == 0) taxonomy = filter.data('slug');
if (taxonomy in wpfExistTerms) {
jQuery.each(wpfExistTerms[taxonomy], function( index, value ){
index = index.toLowerCase();
var els = jQuery('body').find('div.wpfShowCount[data-taxonomy="'+taxonomy+'"] [data-term-id="'+index+'"]');
if (els.length === 0) {
els = jQuery('body').find('div.wpfShowCount[data-slug="'+taxonomy+'"] [data-term-id="'+index+'"]');
}
if(els.length > 0) {
els.each(function() {
var el = jQuery(this);
if (el.find('.wpfCount').length > 0) {
el.find('.wpfCount').html('('+value+')');
} else if (el.parent().attr('class') == 'wpfColorsColBlock') {
el.parent().find('.wpfCount').html('('+value+')');
} else {
var attrname = el.attr('data-term-name');
var tooltipstered = el.siblings('.tooltipstered');
if (tooltipstered.length) {
attrname = tooltipstered.attr('data-term-name');
tooltipstered.tooltipster('content', ''+attrname+' ('+value+')');
} else if (attrname !== undefined) {
el.html(''+attrname+' ('+value+')');
} else {
el.html(''+index+' ('+value+')');
}
}
if(el.is('option')) {
el.attr('data-count', value);
}
});
}
});
}
}
});
window.wpfFrontendPage.disableLeerOptions();
jQuery('.wpfShowCount').find('select[multiple]').multiselect('reload');
};
// show/hide individual filter itemss
function wpfShowHideFiltersAtts(wpfExistTerms, wpfExistUsers) {
var curFilter = window.wpfFrontendPage.currentLoadId;
jQuery((curFilter ? '#' + curFilter + ' ' : '') + '.wpfFilterWrapper').each(function(){
var filter = jQuery(this),
filterType = filter.data('filter-type'),
filterContentType = filter.data('content-type'),
taxonomy = filter.data('taxonomy'),
getAttr = filter.data('get-attribute'),
isFilterCurentlyActivated = getParameterByName(getAttr, location.search),
isShowAll = Boolean(filter.data('show-all')),
isNotInLogic = getAttr.indexOf('pr_filter') == -1 ? false : true,
userExistIds = [];
for(var userData of wpfExistUsers) {
userExistIds.push(parseInt(userData['ID']));
}
switch (filterContentType) {
case 'user':
if ( !isFilterCurentlyActivated ) {
filter.find('[data-term-id]').each(function () {
var el = jQuery(this),
userId = el.data('term-id');
if (userExistIds.indexOf(userId) >= 0) {
el.show();
} else {
el.hide();
}
});
}
break;
case 'taxonomy':
if (typeof taxonomy == 'undefined' || taxonomy.length == 0) {
taxonomy = filter.data('slug');
}
if (!isFilterCurentlyActivated && !isNotInLogic && !isShowAll ) {
if (taxonomy in wpfExistTerms) {
var termIds = wpfExistTerms[taxonomy];
filter.find('[data-term-id]').each(function () {
var elem = jQuery(this),
id = elem.data('term-id');
if (id in termIds) {
if(elem.closest('.wpfButtonsFilter').length) elem.css('display', 'inline-block');
else elem.show();
if (elem.parent().hasClass('wpfColorsColBlock')) {
elem.parent().parent().show();
}
if (elem.closest('.wpfColorsRow').length) {
elem.parent().css('display', 'inline-block');
}
} else {
elem.hide();
elem.find('input').prop('checked', false);
if (elem.parent().hasClass('wpfColorsColBlock')) {
elem.parent().parent().hide();
}
}
});
if (filter.attr('data-display-type') == 'slider' ) {
if ( filter.find('.ion-range-slider').data('values') ) {
filter.show();
} else {
filter.hide();
}
} else {
// all terms display block already has css display none
if (filter.find('[data-term-id][style*="none"]').length == filter.find('[data-term-id]').length) {
filter.hide();
} else {
filter.show();
}
}
} else {
filter.find('input').prop('checked', false);
filter.find('select').val('');
filter.hide();
}
}
filter.find('select[multiple]').multiselect('reload');
if(typeof(window.wpfFrontendPage.wpfShowHideFiltersAttsPro) == 'function') {
window.wpfFrontendPage.wpfShowHideFiltersAttsPro(filter);
}
break;
default:
// console.log(`Sorry, we are out of ${expr}.`);
}
});
}
function wpfChangePriceFiltersCount(prices) {
var _thisObj = window.wpfFrontendPage,
noWooPage = _thisObj.noWoo,
filterWrapper = jQuery('.wpfMainWrapper'),
priceFilters = jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"].wpfNotActive');
jQuery('.wpfFilterWrapper[data-filter-type="wpfPrice"]').each(function () {
var wpfPrice = jQuery(this);
wpfPrice.attr('data-minvalue', prices.min_price).attr('data-maxvalue', prices.max_price);
wpfPrice.find('#wpfMinPrice').attr('min', prices.min_price).val(prices.min_price);
wpfPrice.find('#wpfMaxPrice').attr('max', prices.max_price).val(prices.max_price);
if (wpfPrice.find(".ion-range-slider").length) {
wpfPrice.find(".ion-range-slider").each(function () {
jQuery(this).attr('data-min', prices.min_price).attr('data-max', prices.max_price);
var ionSlider = jQuery(this).data("ionRangeSlider");
ionSlider.update({
min: prices.min_price,
max: prices.max_price,
});
});
}
});
window.wpfFrontendPage.eventsPriceFilter();
/*if (typeof(window.wpfFrontendPage.eventsFrontendPro) == 'function') {
window.wpfFrontendPage.eventsFrontendPro();
}*/
}
function hideFilterLoader( wrapper ) {
wrapper.find('.wpfLoaderLayout').hide();
wrapper.css({
position: ''
});
wrapper.find('.wpfFilterWrapper').css({
visibility: 'visible'
});
}
function heightIdenticalInRow(selector) {
var setMaxHeight = function (elements) {
if (elements.length > 1) {
var elementHeightMax = elements[0].height;
for (var j = 1; j < elements.length; j++) {
if (elements[j].height > elementHeightMax) {
elementHeightMax = elements[j].height;
}
}
for (var j = 0; j < elements.length; j++) {
jQuery(elements[j].selector).height(elementHeightMax);
}
}
};
var elementsHeight = [];
var rowIndex = 0;
var elementIndex = 0;
jQuery(selector).each(function (index, element) {
if (!elementsHeight[rowIndex]) {
elementsHeight[rowIndex] = [];
}
if (
elementsHeight[rowIndex][elementsHeight[rowIndex].length - 1]
&&
elementsHeight[rowIndex][elementsHeight[rowIndex].length - 1].top
&&
elementsHeight[rowIndex][elementsHeight[rowIndex].length - 1].top !== jQuery(element).offset().top
) {
setMaxHeight(elementsHeight[rowIndex]);
rowIndex++;
}
if (!elementsHeight[rowIndex]) {
elementsHeight[rowIndex] = [];
}
elementsHeight[rowIndex].push({
selector: selector + ':eq(' + elementIndex + ')',
height: jQuery(element).height(),
top: jQuery(element).offset().top
});
elementIndex++;
});
if (elementsHeight[rowIndex]) {
setMaxHeight(elementsHeight[rowIndex]);
}
};